From Xojo Documentation
Returns the text encoding of the passed String.
|result||TextEncoding||The text encoding of str.|
|str||String||The string whose TextEncoding will be returned.|
Use the Encoding function to determine the encoding of a string. This is useful for text that you have read in from an external source, for example, with TextInputStream and you don't know the encoding. For text that is generated within REALbasic, the encoding is known to REALbasic.
If the string's encoding is unknown, Encoding returns Nil. Test whether the TextEncoding object is Nil or include an Exception block if there is a chance the string's encoding would not be known at runtime.
The following example gets the encoding of the text stored in the local variable, s. The Exception block handles the call to one of the TextEncoding object's properties if the encoding cannot be determined or the file cannot be opened.