Static codepage CP_UTF8 behaves different than other codepages
Original Reporter info from Mantis: Michl @michl1
-
Reporter name: Michl
Original Reporter info from Mantis: Michl @michl1
- Reporter name: Michl
Description:
This is the new bug report for #29625 (closed). IMHO a string with a static codepage shouldn't change its codepage. It works as excepted for some codepages I've tested but not for CP_UTF8 (65001).
Steps to reproduce:
program Project1;
{$codepage utf8}
type
CP1252String = Type String(1252);
MyStaticCodePageString1 = Type String(1251);
MyStaticCodePageString2 = Type String(CP_UTF8);
const
cp1252ae: CP1252String = #$E4; // ä
var
s: String;
s1: MyStaticCodePageString1;
s2: MyStaticCodePageString2;
begin
s := cp1252ae;
WriteLn(StringCodePage(s), ' correct 1252');
s1 := cp1252ae;
WriteLn(StringCodePage(s1), ' correct 1251');
s1 := s;
WriteLn(StringCodePage(s1), ' correct 1251');
s2 := cp1252ae;
WriteLn(StringCodePage(s2), ' correct 65001');
s2 := s;
WriteLn(StringCodePage(s2), ' wrong 1252, should be 65001');
Readln;
end.
Additional information:
If that behaviour is correct, it should be documented. I can't find any info why codepage UTF8 behaves in that way (not like a other codepage):
http://wiki.freepascal.org/FPC_Unicode_support#Static_code_page
http://www.freepascal.org/docs-html/ref/refse13.html#QQ2-33-43
Mantis conversion info:
- Mantis ID: 29651
- OS: 7
- OS Build: 64bit
- Build: 33098
- Platform: Windows
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 1290 (#18c1e2fb)
- Target version: 3.0.2