Encodings Module

Returns the specified TextEncoding.

# Properties

None

# Methods

None

# Notes

result=Encodings.EncodingsName

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.

The Encodings object makes it easy to obtain a specified TextEncoding. Any text encoding can be obtained via the Encodings object. Some of the most useful are UTF8, UTF16, ASCII, MacRoman, MacJapanese, and WindowsLatin1. Use the Autocomplete feature of the Code Editor to view the complete list.

# Example

Use the Chr method of the TextEncoding class to get a specific character in any encoding scheme. You use the Encodings object 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 REALbasic, you should specify its encoding so that REALbasic can interpret the byte string correctly. Use the Encodings object to get the encoding and pass it to the Encoding property of the TextInputStream class. This example specifies the MacCentralEurRoman encoding.

Dim f As FolderItem
Dim t As TextInputStream
f= GetOpenFolderItem("text")
If f <> Nil then
t=f.OpenAsTextFile
t.Encoding=Encodings.MacCentralEurRoman
EditField1.text=t.ReadAll
t.Close
End if

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

## See Also

TextEncoding class; DefineEncoding, ConvertEncoding, Encoding functions.