[fpc-devel] Unicode proceedings

Sven Barth pascaldragon at googlemail.com
Thu Nov 17 14:55:26 CET 2011


Am 17.11.2011 12:59, schrieb Michael Schnell:
>> Note that the Delphi2009 definition is theoretically capable of
>> combining one and
>> two bytes in one type (like Yury's).
> As I don't have such a Delphi please help me to understand:
>
> Is there a general type dedicated for being able to hold any encoding ?
> (be it ANSIxyz, UTF-8 or UTF-16) ?

In theory the AnsiString type (which is now the code page aware string 
type) should be capable of holding UTF-8 and UTF-16 data, but either the 
direct unconverted storage of 2 byte data (UTF-16) is forbidden or 
undefined (don't remember which one it is in Delphi).

> Such "assignment" can happen with ":=", and with function calls. With
> function calls there is "value" and "var" parameters. All this should
> behave identical, any other behavior would be very hard to understand.

Don't forget about "out". As it sets the string to empty I don't know by 
myself what Delphi does here (e.g. what codepage the string will contain).

>
> And on top of this: what is the type "String" ? Of course the general
> String type would be an obvious choice, but perhaps (depending on the
> implementation) this might result in worse performance in certain cases
> of usage and thus some strict (specifically encoded) Type could be
> chosen. (In fact I will never again use "String" in any project, but use
> a propriety type defined in some central unit so that I at any time can
> do a central change to some specific string type.)

In Delphi the type "String" is an alias to "UnicodeString", thus a 
2-byte string. In FPC there is no final decision yet and thus currently 
"String" is an "AnsiString" set to a specific codepage (though I 
honestly don't know which one it is...).

Regards,
Sven



More information about the fpc-devel mailing list