Problem with ord () and string

i having this problem if i:

mychr = '';

where the "space" in mychr is equivalent to # 255 (manually entered by ALT + 255), and I write:

myord = ord (mychr)

to myord returns 160, not 255. Of course, the same problem is also with charater ALT + 254, etc. How can I solve this problem? I tested on delphi xe in console mode.

Note: if I use:

mychar = # 255;

then the ord () function will return the value correctly.

+3
source share
3 answers

, , Windows Alt + Num , Delphi Unicode, (, , 127). , #255 . , "" , , ! , .pas. #255. ,

const
  MY_PRECIOUS_VALUE = #255;

, .

Alt:

, , 0 (), Windows, . , Windows-1252. . . 0 (), DOS . DOS . , , 437. , , 850. , . .

, Alt- Alt, Alt 0255 .

+8

ALT+255, DOS; 437 850 DOS ( , , ) # 255 - NBSP ( ). Unicode NBSP $A0 (160). , Ord 160.

+3

AFAIK OEM Ansi char. Delphi XE Ansi, UCS-2/Unicode.

var MyChar: char;
    MyWideChar: WideChar; 
    MyAnsiChar: AnsiChar;
begin
  MyChar := #255;
  MyWideChar := #255;
  MyAnsiChar := #255;

, .. 255 = $00FF, Delphi XE, char = WideChar. . .

MyAnsiChar - , , OEM.

Unicode $00FF - y :

U+00FF ÿ Latin Small Letter Y with diaeresis

OEM char, .. Page 347. , $FF ,

FF  NBSP  Non Breaking SPace

U + 00A0 Unicode:

U+00A0 NBSP  Non Breaking SPace

, Windows-1252, Delphi XE AnsiString # 255 minuscule y :

FF ÿ Latin Small Letter Y with diaeresis

, . CharToOemBuff OEM OEM- AnsiString:

type
  TOemString = AnsiString(437);

Windows Unicode Delphi XE.

InputQuery, . , Unicode string.;)

+1

All Articles