[fpc-devel] new string - question on usage

Hans-Peter Diettrich DrDiettrich1 at aol.com
Wed Oct 12 13:53:57 CEST 2011


Michael Schnell schrieb:
> On 10/12/2011 10:35 AM, Sven Barth wrote:
>>
>> No. In Delphi "String = UnicodeString", but AnsiString still exists as 
>> a one-byte (or multi-byte) string type (the "new string type" or "code 
>> page aware string type").
> Sorry, but I don't understand.
> 
> According to the "TAnsiRec", such a "New String" not only  has an 
> encoding ID, but also an "ElementSize" specification.
> 
> So an "ANSIString" that uses the TAnsiRec for it's implementation 
> obviously is capable of holding of 1, 2 and 4 byte encoded data.

Ansi and Unicode strings share the same header structure. This would 
allow, in theory, to use only one (polymorphic) string type everywhere. 
In fact this common structure only allows to find out about the 
properties of an given string, it does not imply any assignment 
compatibility.

All AnsiString types have an element size of 1, UnicodeString has 2 and 
UCS4String has 4 bytes per element.

DoDi




More information about the fpc-devel mailing list