Hi, I found a bug in FPC, at least there is a difference of how the Wide to Ansi string conversioni the Delphi does.
Imagine, if you have a char §, it's byte value is 0xA7.
- In WideString this char is interpreted like two bytes 0x00 0xA7, that's OK
- In AnsiString, this char is interpreted like a byte 0xA7, that's OK
- But, if you convert this WideString to AnsiString, in AnsiString this char will be interpreted as two bytes 0xC2 0xA7, which is wrong!
Example:
var
w : WideString;
s : AnsiString;
begin
w := '§';
s := AnsiString(w);
// "s" here contains two bytes 0xC2 0xA7, instead of just one 0xA7
end;
Btw, Delphi does conversion correctly. Who knows how to done the conversion correctly?