How to transfer characters expressed as decimal places?

How to transfer characters expressed as decimal places (# 0, # 1, # 9, # 10, # 13, # 32, # 128, # 255) in Delphi 7 in Delphi Unicode? Some documents (such as "Delphi in the Unicode World" by Embarcadero) only say that they should be replaced with the actual character. For example, instead of # 128, I should use "€". But what would you do C # 0 ??? Or number 9? Or # 13?


Update:

This seems like a tricky question. Someone said here that all characters under 128 remain unchanged. However, "Delphi in the Unicode world" states otherwise. So, is there a way to use something like # 9 in Delphi XE or port code from Delphi 7 to Delphi Unicode, which is due to big code changes?

+3
source share
1 answer

The low half of ANSI codes [# 0 .. # 127] does not change after conversion to Unicode, so you should not worry about that. The high half [# 128 .. # 255] is harder. The compiler interprets strings

const s1:AnsiString = #200;
const s2:UnicodeString = #200;

depending on the directive {$ HIGHCHARUNICODE}

{$HIGHCHARUNICODE OFF}          // default setting on Delphi 2009
const s1:AnsiString = #200;     // Ord(s1[1]) = $C8 = 200
const s2:UnicodeString = #200;  // Ord(s2[1]) depends on Codepage
                                //  on my Win1251 = $418  

{$HIGHCHARUNICODE ON}
const s1:AnsiString = #200;     // Ord(s1[1]) depends on Codepage
                                //   on my Win1251 = $45
const s2:UnicodeString = #200;  // Ord(s2[1]) = $C8 = 200

# 200 - "And" on the Win1251 code page. The Unicode code for "AND" is $ 418.

Unicode # 200, on the other hand, has a È. Win1251 does not have a “È” character, and a Unicode → Win1251 conversion converts it to “E”, which is # 45 US dollars for all ANSI code pages.

With {$ HIGHCHARUNICODE OFF}, the compiler interprets the characters # 128 .. # 255 as ANSI characters depending on the system code page and, if necessary, converts them to Unicode code pages.

{$ HIGHCHARUNICODE ON} # 128.. # 255 Unicode , , ANSI .


Nick, Unicode Delphi:

var
  Buf: array[0..32] of Char;
begin
  FillChar(Buf, Length(Buf), #9);
  ShowMessage(Format('%d %d %d', [Ord(Buf[0]), Ord(Buf[0]), Ord(Buf[16])]));
end;

FillChar; FillChar (BTW Buf ) Unicode. FillChar FillBytes (# 9) .

+6

All Articles