To load a text file in Unicode, you need to know its encoding. If the file has a byte order sign (BOM), you can simply call LoadFromFile(FileName)
, and RTL will use the specification to determine the encoding.
If there is no specification in the file, you need to explicitly specify the encoding, for example.
LoadFromFile(FileName, TEncoding.UTF8); LoadFromFile(FileName, TEncoding.Unicode);//UTF-16 LE LoadFromFile(FileName, TEncoding.BigEndianUnicode);//UTF-16 BE
For some reason, unknown to me, there is no native support for UTF-32, but if you had such a file, it would be enough to simply add a TEncoding
instance to handle this.
source share