How to force fixed length Delphi strings to use wide characters?

In Delphi 2010 (and probably in D2009 as well), the default row type is UnicodeString.

However, if we announce ...

const
 s  :string = 'Test';
 ss :string[4] = 'Test';

... then the first line of s , if declared as a UnicodeString , but the second line of 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 announce ...

var
  s  :string;
  ss :string[4];

... than I want ss to also be a UnicodeString type.

  • How can I tell Delphi 2010 that both strings should be UnicodeString types?
  • , ss WideChars? WideString[4] UnicodeString[4].
  • : ?
+3
2

, string[n], ShortString, . Embarcadero ShortString Unicode. , , Delphi 2 .

WideChar, array [1..n] of char.

+9
  • string[4] . .

  • Char, 4 WideChars.

  • a string[4] , 4 . , WideChars , : ) , b) . ShortStrings AnsiStrings, [x] .

+4

Source: https://habr.com/ru/post/1787696/


All Articles