Unit
SysUtils has a singleton class
TEncoding. When changing DefaultSystemCodePage, like in Lazarus under Windows, TEncoding.Default.EncodingName does not get updated.
In theory calling TEncoding.FreeEncodings should be enough except that it does not assign nil to TEncoding.FStandardEncodings:
for E := Low(FStandardEncodings) to High(FStandardEncodings) do
FStandardEncodings[E].Free;
The only way I found to get over this issue is to create a descendant class like TMBCSEncoding to reach to the strict private constructor:
TEncoding = class
strict private
...
class constructor Create;
...
class constructor TEncoding.Create;
var
E: TStandardEncoding;
begin
for E := Low(FStandardEncodings) to High(FStandardEncodings) do
FStandardEncodings[E] := nil;
end;
Is that a bug or intended design?
Edit:
Bug reported:
33681 and fixed!