Under Delphi 2010 (and probably under D2009 also) the default string type is UnicodeString.
However if we declare...
const
s :string = 'Test';
ss :string[4] = 'Test';
... then the first string s if declared as UnicodeString, but the second one ss is declared as AnsiString!
We can check this: SizeOf(s[1]);
will return size 2 and SizeOf(ss[1])
; will return size 1.
If I declare...
var
s :string;
ss :string[4];
... than I want that ss is also UnicodeString type.
- How can I tell to Delphi 2010 that both strings should be UnicodeString type?
- How else can I declare that ss holds four WideChars? The compiler will not accept the type declarations
WideString[4]
orUnicodeString[4]
. - What is the purpose of two different compiler declarations for the same type name: string?
WideString
; it'sUnicodeString
. They both use wide chars, but the semantics are very different. For one thing,WideString
is not reference-counted, butUnicodeString
is. – Lasso