From Xojo Documentation
Jump to: navigation, search

Returns the specified TextEncoding.

Count Item


You can use the following syntax to easily get any TextEncoding object:

myEncoding = Encodings.EncodingName

where EncodingName is one of the following

Encoding Names
ASCII ISOLatinGreek MacRomanLatin1
DOSArabic ISOLatinHebrew MacRomanian
DOSBalticRim KOI8_R MacSinhalese
DOSCanadianFrench MacArabic MacSymbol
DOSChineseSimplif MacArmenian MacTamil
DOSChineseTrad MacBengali MacTelugu
DOSCyrillic MacBurmese MacThai
DOSGreek MacCeltic MacTibetan
DOSGreek1 MacCentralEurRoman MacTurkish
DOSGreek2 MacChineseSimp MacVietnamese
DOSHebrew MacChineseTrad ShiftJIS
DOSIcelandic MacCroatian SystemDefault
DOSJapanese MacCyrillic UCS4 (2012r1 and earlier)
DOSKorean MacDevanagari UTF16
DOSLatin1 MacDingbats UTF16BE
DOSLatin2 MacEthiopic UTF16LE
DOSLatinUS MacExtArabic UTF32 (2012r2 and later)
DOSNordic MacGaelic UTF32BE
DOSPortuguese MacGeorgian UTF32LE
DOSRussian MacGreek UTF8
DOSThai MacGujarati WindowsANSI
DOSTurkish MacGurmukhi WindowsArabic
ISOLatin1 MacHebrew WindowsBalticRim
ISOLatin2 MacIcelandic WindowsCyrillic
ISOLatin3 MacJapanese WindowsGreek
ISOLatin4 MacKannada WindowsHebrew
ISOLatin5 MacKhmer WindowsKoreanJohab
ISOLatin6 MacKorean WindowsLatin1
ISOLatin7 MacLaotian WindowsLatin2
ISOLatin8 MacMalayalam WindowsLatin5
ISOLatin9 MacMongolian WindowsVietnamese
ISOLatinArabic MacOriya
ISOLatinCyrillic MacRoman


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 function to first get the desired encoding. For example:

Dim s as String
s = Encodings.UTF8.Chr(169)

When you read a string that was created outside your app, you should specify its encoding so that the byte string can be interpreted correctly. Use the Encodings function 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.

Dim f As FolderItem
Dim t As TextInputStream
f = GetOpenFolderItem(FileTypes1.Text)
If f <> Nil then
t = TextInputStream.Open(f)
t.Encoding = Encodings.MacCentralEurRoman
End If

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

See Also

TextConverter, TextEncoding, TextInputStream classes; DefineEncoding, ConvertEncoding, GetInternetTextEncoding, Encoding functions.

Personal tools

Starting Out
Dig Deeper
More Help