A static codepage doesn't exists for new strings
Original Reporter info from Mantis: Michl @michl1
-
Reporter name: Michl
Original Reporter info from Mantis: Michl @michl1
- Reporter name: Michl
Description:
The documentation here http://www.freepascal.org/docs-html/ref/refse13.html#QQ2-33-43 says:
Since strings have code page information associated with them, it is important
to know which code page a string uses:
...
Single byte strings with declared code page use that code page.
...
Type
TString1 = Type String(1252);
TString2 = Type String(1251);
Var
A : TString1;
B : TString2;
begin
A:=’123’+’345’+intToStr(123);
B:=A;
Writeln(’B : ’,StringRefCount(B));
Writeln(’A : ’,StringRefCount(A));
end.
The compiler will convert the contents in string B to the codepage of string A
On a other place such a declared string has a "static" codepage: http://wiki.freepascal.org/FPC_Unicode_support#Static_code_page
If you make a simple test:
program Project1;
{$codepage utf8}
const
cp1252ae = #$E4;
var
us: UTF8String;
rs: RawByteString;
begin
rs := cp1252ae;
SetCodePage(rs, 1252, False);
us := rs;
WriteLn(StringCodePage(us));
Readln;
end.
You will see that the "static" UTF8String has the codepage 1252.
I don't know what behaviour is correct, but either the documentation or the conversion should be changed.
Additional information:
There is a litte thread on german Lazarusforum: http://www.lazarusforum.de/viewtopic.php?f=10&t=9436
Mantis conversion info:
- Mantis ID: 29625
- OS: 7
- OS Build: 64bit
- Build: 33042
- Platform: Windows
- Version: 3.1.1