[fpc-devel] Encoded AnsiString

Sven Barth pascaldragon at googlemail.com
Sun Dec 29 20:00:50 CET 2013


On 29.12.2013 19:26, Hans-Peter Diettrich wrote:
> Jonas Maebe schrieb:
>
>> The code page of ansistrings concatenations is the code page of the
>> result to which this concatenation is assigned/converted. For
>> rawbytestring, this code page is CP_ACP per Delphi compatibility.
>
> This does not match my experience with Delphi XE :-(
>
> Can you give an Delphi example, so that I can verify this behaviour?

=== code begin ===

program tstrtest;

{$apptype console}

procedure Test(aArg: RawByteString);
begin
   Writeln(StringCodePage(aArg));
end;

type
   CP1252String = type AnsiString(1252);

var
   s1: UTF8String;
   s2: CP1252String;
begin
   s1 := 'Test';
   s2 := 'Test';
   DefaultSystemCodePage := 1251;
   Test(s1);
   Test(s2);
   Test(s1 + s2);
end.

=== code end ===

This will print

=== output begin ===

65001
1252
1251

=== output end ===

This was tested using Delphi XE (it might not compile though as I've 
just rewritten the code from memory as the original is on a different 
computer)

Regards,
Sven



More information about the fpc-devel mailing list