Xojo.Core.TextEncoding.ConvertTextToData
From Xojo Documentation
Method
Xojo.Core.TextEncoding.ConvertTextToData(value As Text, allowLossy As Boolean = False) As Xojo.Core.MemoryBlock
Supported for all project types and targets.
Supported for all project types and targets.
Converts a text value to bytes in a MemoryBlock.
Parameters
Parameter | Description |
---|---|
value | The Text value to convert. |
allowLossy | When True, any characters that cannot be represented are replaced with a question mark. |
Notes
If the value cannot be represented accurately in this encoding, an exception is raised. The allowLossy parameter can be used to override this behavior. If it is True, any characters that cannot be represented are replaced with a question mark. For example, Emoji is not representable in the ASCII encoding.
If the encoding is UTF-16 or UTF-32, the resulting data will begin with a byte order mark. If the byte order mark is not desired, the encoding should specify an explicit big endian or little endian (e.g. using UTF32LittleEndian).
Exceptions
- RuntimeException if value cannot be represented accurately in the encoding and allowLossy is False.
Sample Code
Convert text to UTF-8 data: