[fpc-pascal] FPC 3: disabling automatic AnsiString codepage conversion

Michael Van Canneyt michael at freepascal.org
Mon Apr 4 10:32:58 CEST 2016



On Mon, 4 Apr 2016, Tobias Giesen wrote:

> Hello,
>
> my application uses the AnsiString type to store UTF-8 data. That was
> totally fine. Now in FPC 3, automatic conversions cause data loss. I
> get question marks replacing Chinese characters, for example.
>
> I do not fully understand at which points these conversions are done.
> The FPC 3 Unicode documentation says something about "passing it to a
> RTL routine".
>
> What about this code:
> var a,b:Ansistring;
> begin
>  a:=Utf8Encode(AWideString);
>  b:=Copy(a,1,10);
>  end;
>
> Is "Copy" an RTL routine? Is this OK or not?
>
> Best for me would be to be able to turn the conversions off completely.

You cannot, but you can set DefaultSystemCodePage to CP_UTF8.
Then no conversions will be done for all ansistrings that contain UTF8.

Michael.



More information about the fpc-pascal mailing list