Xojo.Core.TextEncoding.ConvertDataToText
From Xojo Documentation
Method
Xojo.Core.TextEncoding.ConvertDataToText(data As Xojo.Core.MemoryBlock, allowLossy As Boolean = False) As Text
Supported for all project types and targets.
Supported for all project types and targets.
Converts a chunk of data in a MemoryBlock to Text.
Parameters
Parameter | Description |
---|---|
data | A MemoryBlock containing the data to convert. |
allowLossy | When True, any characters that cannot be represented are replaced with the Unicode replacement character (U+FFFD). |
Notes
Converts a chunk of data to Text. If the data is not valid for this encoding (e.g. overlong UTF-8 sequences), an exception is raised. The allowLossy parameter can be used to override this behavior. If it is True, any invalid input is replaced with the Unicode replacement character (U+FFFD).
Exceptions
- NilObjectException if data is Nil.
- RuntimeException if data is not valid for the encoding and allowLossy is False or if data has an unknown size.
Sample Code
This code takes data that came in on a MemoryBlock from an Xojo.Net.HTTPSocket.PageReceived event and converts it to UTF8 Text: