Delphi XE2 Constants AnsiFormat () and ANSI String

Is there a convenient Format () function that works only on Ansi strings? Since every time I use AnsiString with Format (), I get a warning. And no, I don't want Delphi to convert my AnsiStrings back and forth between the Wide and Ansi strings. It just makes things awfully slow. Also, is there a way to get the string constant to be Ansi? check this

function SomeStrFunc(S: AnsiString): AnsiString; overload;
function SomeStrFunc(S: String): String; overload;

and then when I use SomeStrFunc ('ABC'), it will call the widescreen version. What if I want to use the Ansi version and force Delphi to keep the "ABC" constant in AnsiChars.

+5
source share
2

Ansi Format System.AnsiStrings unit

+11

AnsiString Format(). .

, , , , :

SomeStrFunc(AnsiString('ABC'));

const
  cABC: AnsiString = 'ABC';

SomeStrFunc(cABC);
+7

All Articles