On 26.12.2019 16:41, Mattias Gaertner via fpc-devel wrote:
On Thu, 26 Dec 2019 16:15:03 +0100
Ondrej Pokorny <laza...@kluug.net> wrote:

Hello,

a lot of people have a problem with the TStrings.LoadFrom*() changes
when TEncoding support was added.

Currently, the no-encoding overloads of TStrings.LoadFrom*() and
TStrings.SaveTo*() use the TEncoding.Default, which is WIN-ANSI and
not DefaultSystemCodePage.
It seems FPC 3.3.1 does use DefaultSystemCodePage:

class function TEncoding.GetANSI: TEncoding;
begin
   ....
     if not Assigned(FStandardEncodings[seAnsi]) then
     begin
       // DefaultSystemCodePage can be set to non-ANSI
       if Assigned(widestringmanager.GetStandardCodePageProc) then
         FStandardEncodings[seAnsi] := 
TMBCSEncoding.Create(widestringmanager.GetStandardCodePageProc(scpAnsi))
       else
         FStandardEncodings[seAnsi] := 
TMBCSEncoding.Create(DefaultSystemCodePage);
    ...
end;

Check the code more carefully. It uses DefaultSystemCodePage only when no widestringmanager is present - which is basically never the case (at least on win32, Linux, Mac OS).

It uses widestringmanager.GetStandardCodePageProc(scpAnsi) that is WIN-ANSI on win32 (typically 1250, 1251, 1252 - depending on your OS language version).

Ondrej

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

Reply via email to