String constant : unexpected conversion
Original Reporter info from Mantis: DarekM
-
Reporter name: Darek Mazur
Original Reporter info from Mantis: DarekM
- Reporter name: Darek Mazur
Description:
I've play with some strin constans,
My source file original are from Delphi, thus prefer 1250 codepage,
but from fpc3.0 have some problems.
I dont know how to store utf8 string constant on 1250 source file.
I've made some test (when code page equals zero of cp1250):
when const string are assign to ansisting, and after that assign to utf8string
the is no conversion (i was thinking it should be)
but assign constant invoke weird implicit conversion
on source with code page utf8 all is as expected;
Steps to reproduce:
{.$codepage utf8}
{$codepage cp1250}
{.$codepage cp1252}
{.$codepage 8859-2}
program testString;
var
s : utf8String;
so : rawbyteString;
sa : ansiString;
begin
so:=#115#$C4#$87;
if $C4<>ord(so[2]) then halt(1);
writeln(stringcodepage(so),' 1: ',so,length(so)); //codepage=1250
so:=rawByteString(#115#$C4#$87);
writeln(stringcodepage(so),' 2: ',so,length(so)); //codepage=1250
if $C4<>ord(so[2]) then
halt(2);
sa:=#115#$C4#$87;
writeln(stringcodepage(sa),' 3: ',sa,length(sa));
if $C4<>ord(sa[2]) then halt(3);
s:=sa;
writeln(stringcodepage(s),' 4: ',s,length(s)); //codepage=65001,no conversion, only change codepage
// s:=rawString(#115#196#$87);
if $87<>ord(s[3]) then halt(4);
if 196<>ord(s[2]) then halt(5);
s:=#115#$C4#$87;
writeln(stringcodepage(s),' 5: ',s,length(s)); //codepage=65001,length =6, unexpected conversion
s:=rawByteString(#115#$C4#$87);
writeln(stringcodepage(s),' 6: ',s,length(s)); //codepage=65001,length =6 ,unexpected conversion
if $87<>ord(s[3]) then halt(6);
if 196<>ord(s[2]) then halt(7);
writeln('OK');
end.
Mantis conversion info:
- Mantis ID: 29170
- OS: Linux
- Version: 3.0.0