From Xojo Documentation

Revision as of 19:09, 19 November 2009 by (talk) (Examples)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Returns the specified TextEncoding.



Part Type Description
result TextEncoding The text encoding specified by EncodingsName.
EncodingsName String The name of a TextEncoding. Use the Code Editor's AutoComplete feature to show all possible values of EndodingsName.


Name Parameters Return Type Description
Introduced 2008r2
Integer Returns the number of encodings in the built-in list of encodings.
Introduced 2008r2
Index as Integer TextEncoding Returns the specified element of the list of encodings by its index. Index is zero-based.


The Encodings module makes it easy to obtain a specified TextEncoding. Any text encoding can be obtained via the Encodings module. Some of the most useful are UTF8, UTF16, ASCII, MacRoman, MacJapanese, and WindowsLatin1. It includes the UTF16BE (big endian) and UTF16LE (little endian) encodings for reading and writing encoded text to files on computers that require either big or little endianness.

Use the Autocomplete feature of the Code Editor to view the complete list.


Use the Chr method of the TextEncoding class to get a specific character in any encoding scheme. You use the Encodings module to first get the desired encoding. For example:

Dim s as String

When you read a string that was created outside REALbasic, you should specify its encoding so that REALbasic can interpret the byte string correctly. Use the Encodings module to get the encoding and pass it to the Encoding property of the TextInputStream class. This example specifies the MacCentralEurRoman encoding.

The Text file type was defined in the File Type Sets editor as one of the common file types.

If f <> Nil then
End if

You can also specify the encoding of text using the optional parameter of the Read, ReadLine, or ReadAll methods.

See Also

TextConverterTextEncoding, TextInputStream classes; DefineEncoding, ConvertEncoding, Encoding functions.