How can I make fixed-length Delphi strings use wide characters? -
under delphi 2010 (and under d2009 also) default string type unicodestring.
however if declare...
const s :string = 'test'; ss :string[4] = 'test';
... first string s if declared unicodestring, second 1 ss declared ansistring!
we can check this: sizeof(s[1]);
return size 2 , sizeof(ss[1])
; return size 1.
if declare...
var s :string; ss :string[4];
... want ss unicodestring type.
- how can tell delphi 2010 both strings should unicodestring type?
- how else can declare ss holds 4 widechars? compiler not accept type declarations
widestring[4]
orunicodestring[4]
. - what purpose of 2 different compiler declarations same type name: string?
the answer lies in fact string[n]
, shortstring
, considered legacy type. embarcadero took decision not convert shortstring
have support unicode. since long string introduced, if memory serves correctly, in delphi 2, seems reasonable decision me.
if want fixed length arrays of widechar can declare array [1..n] of char
.
Comments
Post a Comment