Hello,
here are results:
...
begin
Writeln('--------------');
Writeln;
s1 := 'A'; // 1250
s2 := 'Aä'; // 1250
Writeln('s1 = "', s1, '" cp = ', StringCodePage(s1));
Writeln('s2 = "', s2, '" cp = ', StringCodePage(s2));
r1 := AnsiToUTF8(s1); // 65001
r2 := AnsiToUTF8(s2); // 65001
Writeln('r1 = "', r1, '" cp = ', StringCodePage(r1));
Writeln('r2 = "', r2, '" cp = ', StringCodePage(r2));
r3 := s1 + r2; // 1250
Writeln('r3 = "', r3, '" cp = ', StringCodePage(r3));
r3 := r1 + s2; // 65001
Writeln('r3 = "', r3, '" cp = ', StringCodePage(r3));
s3 := s1 + r2; // 1250
Writeln('s3 = "', s3, '" cp = ', StringCodePage(s3));
s3 := r1 + s2; // 65001
Writeln('s3 = "', s3, '" cp = ', StringCodePage(s3));
SetCodePage(RawByteString(s1), 65001, True);
r3 := s1 + r2; // 65001
Writeln('r3="', r3, '" cp=', StringCodePage(r3));
r3 := r1 + s2; // 65001
Writeln('r3="', r3, '" cp=', StringCodePage(r3));
s3 := s1 + r2; // 65001
Writeln('s3="', s3, '" cp=', StringCodePage(s3));
s3 := r1 + s2; // 65001
Writeln('s3="', s3, '" cp=', StringCodePage(s3));
Readln;
end.
(*
--------------
s1 = "A" cp = 1250
s2 = "Aä" cp = 1250
r1 = "A" cp = 65001
r2 = "Aä" cp = 65001
r3 = "AAä" cp = 1250
r3 = "AA?" cp = 65001
s3 = "AAä" cp = 1250
s3 = "AA?" cp = 65001
r3="AAä" cp=65001
r3="AA?" cp=65001
s3="AAä" cp=65001
s3="AA?" cp=65001
*)
------ Původní zpráva ------
Od: "Jonas Maebe" <jonas.ma...@elis.ugent.be>
Komu: "FPC-Pascal users discussions" <fpc-pascal@lists.freepascal.org>
Odesláno: 23.07.2016 13:03:33
Předmět: Re: [fpc-pascal] Weird string behavior
On 23/07/16 12:58, wkitt...@windstream.net wrote:
On 07/23/2016 06:13 AM, Jonas Maebe wrote:
[...]
var
s1,s2,s3: AnsiString;
r1,r2,r3: RawByteString;
begin
s1:='A'; // 1252
s2:='Aä'; // 1252
writeln('s1="',s1,'" cp=',StringCodePage(s1));
writeln('s2="',s1,'" cp=',StringCodePage(s2));
writeln('s2="',s2,'" cp=',StringCodePage(s2));
you're not the only one to have missed that...
The only thing that matters for this test is the stringcodepage value,
which is the correct one.
Jonas
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal