DefineEncoding Function
Returns a String with the same data as the given string, but with the encoding of the given encoding. This function is useful when you have a string whose encoding is known to you but not to REALbasic.
Syntax
result = DefineEncoding( str, enc )
result = str.DefineEncoding( enc )
Parameters | ||
str |
The String to be encoded. |
|
enc |
The TextEncoding to be used to encode str. |
REALbasic 'knows' the encoding of the text it creates, so you don't have to use DefineEncoding for any such text.
Notes
Consult the values of Base entry for TextEncoding when creating the TextEncoding object using the GetTextEncoding function.
Example
The following example takes 8 bytes from a MemoryBlock and sets the encoding to UTF16.
This example uses DefineEncoding when reading text via a TCPSocket.
See Also
TextEncoding class; ConvertEncoding, Encoding, GetTextEncoding functions; Encodings object.