[fpc-devel] TEncoding.Default and default encoding for TStrings.LoadFrom*()

Michael Van Canneyt michael at freepascal.org
Thu Dec 26 19:29:14 CET 2019



On Thu, 26 Dec 2019, Ondrej Pokorny wrote:

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

That this was going to create problems and require code changes in user
code, was clear from the start.


> I suggest a compromise (steps):
>
> 1.) Keep TEncoding.ANSI always WIN-ANSI and Delphi-compatible. (Don't 
> change it to DefaultSystemCodePage in Lazarus.)
> 2.) Change TEncoding.Default value to current TEncoding.SystemEncoding. 
> I.e. TEncoding.Default would correspond to DefaultSystemCodePage and 
> CP_ACP. Yes, this will be Delphi-incompatible - but CP_ACP is 
> Delphi-incompatible as well (!) - so the incompatibilities are 
> consequent here.
> 3.) Delete TEncoding.SystemEncoding because it is an FPC-only construct, 
> it is not needed anymore (because it will become TEncoding.Default) and 
> it has not been released in any stable version.

TEncoding.SystemEncoding was introduced to reflect changes in DefaultSystemCodePage 
whereas TEncoding.Default does not change, it reflects a fixed code page.
What I think should be done is make sure TEncoding.Default is initialized in
the sysutils unit initialization, so it is the actual system default.

So no, I don't think these need to be changed/merged. What IMO can be discussed is
which of these 2 need to be used as the default codepage in other code. It
should then resolve the problems that appear, I think.

Michael.


More information about the fpc-devel mailing list