On Tue, 6 Oct 2020, Bart via fpc-pascal wrote:

On Tue, Oct 6, 2020 at 10:12 AM Michael Van Canneyt via fpc-pascal
<fpc-pascal@lists.freepascal.org> wrote:


// Assume TEncoding.SystemEncoding
Function GetFileAsString(Const aFileName : RawByteString) : RawByteString;
// Specify encoding
Function GetFileAsString(Const aFileName : RawByteString; aEncoding : 
TEncoding) : RawByteString;
// Assume TEncoding.Unicode contents
Function GetFileAsString(Const aFileName : UnicodeString) : UnicodeString;
// Specify encoding, return Unicode string.
Function GetFileAsString(Const aFileName : UnicodeString; aEncoding : 
TEncoding) : UnicodeString;

Now I want to get the contents of a file, which contains either UTF8
or some single-byte encoding, and the filename is NOT in my locale
(e.g. it may be chinese, which I cannot represent in RawByteString),

Of course you can. That is why we use RawByteString for file opening
functions.  You specify it as UTF8 in that case, the RTL will do the rest.

The whole of lazarus works on this principle.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to