[fpc-devel] Some questions and proposals about cpstring
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Thu Oct 13 01:35:52 CEST 2011
Alex Shishkin schrieb:
> 12.10.2011 16:34, Hans-Peter Diettrich пишет:
>> Alex Shishkin schrieb:
>>> 1) Why UTF8String made incompatible with AnsiString(CP_UTF8)
>>> ( UTF8String = type AnsiString(CP_UTF8); )? Why not an alias?
>>
>> An alias allows to assign strings of *any* encoding, with possibly fatal
>> consequences. A strict UTF8String type allows for implicit conversion,
>> whenever required, so that such a string can contain nothing but UTF-8
>> encoded characters.
> So if I declare "MyString : AnsiString(CP_UTF8)" and assign win1251
> encoded string to it no conversion will be made? It`s strange.
Delphi doesn't allow for such syntax. You'll have to write
type TMyString = type AnsiString(CP_UTF8); // = UTF8String
var MyString: TMyString;
Then all assignments to MyString are converted into UTF-8.
DoDi
More information about the fpc-devel
mailing list