With the Embarcadero August 25 release of RAD Studio 2009 (Tiburon's RTM date may be postponed to September-October), with Tiburon full support for Unicode, the existing Delphi /C + + Builder project to migrate to Unicode what should be paid attention to also become the most concerned about the issue. Tiburon support for Unicode is not just a direct conversion of the String type that maps the original type to ansistring, but a modification of the ansistring structure, with the addition of a unicodestring type to perfect support Unicode. This means that in order to migrate smoothly to Unicode, programmers have to make some changes to existing code.
In previous versions of Tiburon, Ansistring and widestring were functionally identical except for data size. The structure of the previous version of the ansistring is as follows:
Format of Ansistring Data Type
| Reference Count |
Length |
String Data (Byte sized) |
Null Term |
| -8 |
-4 |
0 |
Length |
This structure has changed in Tiburon, Ansistring has added two new fields, one is CodePage and the other is Elemsize, which allows the new version of Ansistring and unicodestring to be structurally aligned.
The widestring type is used in earlier versions to hold Double-byte data. Its essence is the same as that of Windows BSTR. In Tiburon, Widestring is still compatible with COM, which means that it still has no reference count, compared to unicodestring, which will be the preferred character type for programs other than COM in terms of performance and efficiency.
UnicodeString type of Flash debut
In Tiburon, the new, default string is the UnicodeString. This type can contain either ANSI characters or Unicode characters. The following is the structure of the unicodestring type:
Format of UnicodeString Data Type
| CodePage |
Element Size |
Reference Count |
Length |
String Data (element sized) |
Null Term |
| -12 |
-10 |
-8 |
-4 |
0 |
Length * ElementSize |
UnicodeString and ansistring are all the above structures, although unicodestring contains double-byte data, Ansistring contains Single-byte.
Using the Object Pascal language to describe the structure of the unicodestring, it should be this:
type
StrRec = record
CodePage: Word;
ElemSize: Word;
refCount: Integer;
Len: Integer;
case Integer of
1: array[0..0] of AnsiChar;
2: array[0..0] of WideChar;
end;