[Lazarus] Making sources compatible with Delphi (but Lazarus is priority)
Ondrej Pokorny
lazarus at kluug.net
Fri May 5 11:31:24 CEST 2017
On 05.05.2017 11:24, Graeme Geldenhuys via Lazarus wrote:
> On 2017-05-05 10:17, Michael Van Canneyt via Lazarus wrote:
>>> Something like:
>>>
>>> sl.LoadFromFile('some_utf8_file.txt', CP_UTF8);
>>> sl.LoadFromFile('some_utf16_file.txt', CP_UTF16);
>>> sl.LoadFromFile('some_latin1_file.txt', CP_Latin1);
>> Not yet. These are the exceptions I was talking about.
>
> That also means FPC 3.0.x is then seriously flawed. It
> supports Unicode, but it also doesn't support Unicode.
>
> So what is the suggested work-around for FPC 3.0.2 to load
> various text encoding files into a TStringList? Hopefully
> the answer is not: "there is none" :-/
Use "DefaultSystemCodePage := CP_UTF8" and you can load any text in any
encoding into TStrings without character loss - the file will be
converted to UTF-8 in LoadFrom* and converted back in SaveTo*. So your
code can handle all encodings equally.
There are no limitations and no problems whatsoever. Yes, FPC is fully
unicode-ready - in case you are fine with using UTF-8 internally!
Ondrej
More information about the Lazarus
mailing list