Character codes

Strings (text) consist of characters (letters, digits, spaces, etc). A character is stored as a numeric value - character code. Different values are displayed as different characters.

 

There are various character sets. Character codes in ANSI character sets consist of single byte. Character codes in the Unicode character set consist of 1-4 bytes (depends on encoding). Characters in range 0 to 127, also called ASCII characters, are the same in all character sets. They are listed in the tables below. To see all characters in all character sets, use Windows program Character Map (run "charmap").

 

Most of characters in range 0 to 31 are rarely used. Often used are these characters:

 

Code Character
0 Terminating null character. Used at the end of a string.
9 Tab.
10 New line, also called linefeed.
13 Carriage return. On Windows, character sequence 13 10 is used for a new line.

 

Other ASCII characters:

 

Code Char   Code Char   Code Char
32 space   64 @   96 `
33 !   65 A   97 a
34 "   66 B   98 b
35 #   67 C   99 c
36 $   68 D   100 d
37 %   69 E   101 e
38 &   70 F   102 f
39 '   71 G   103 g
40 (   72 H   104 h
41 )   73 I   105 i
42 *   74 J   106 j
43 +   75 K   107 k
44 ,   76 L   108 l
45 -   77 M   109 m
46 .   78 N   110 n
47 /   79 O   111 o
48 0   80 P   112 p
49 1   81 Q   113 q
50 2   82 R   114 r
51 3   83 S   115 s
52 4   84 T   116 t
53 5   85 U   117 u
54 6   86 V   118 v
55 7   87 W   119 w
56 8   88 X   120 x
57 9   89 Y   121 y
58 :   90 Z   122 z
59 ;   91 [   123 {
60   92 \   124 |
61 =   93 ]   125 }
62   94 ^   126 ~
63 ?   95 _   127 unused

 

 

QM uses the Unicode character set if the checkbox is checked in Options. Otherwise it uses the default ANSI character set.

 

Characters in the Unicode character set are the same on all computers. Note that not all fonts support all characters.

 

ANSI characters in range 128 to 255 are different (different character is displayed for the same character code) in different ANSI character sets (Western, Baltic, Cyrilic, Greek, etc). The default ANSI character set on a computer depends on the language that is set when installing Windows or changed in Control Panel -> Regional -> Advanced or Administrative -> Language for non-Unicode programs. Therefore these characters can be displayed differently on different computers. You can see characters in various character sets using a Windows program called "Character Map". You can use the first macro in the examples (below) to see how these characters look on your computer.

 

In a macro, to get character code of an ASCII character, enclose the character int single quotes. For example, out 'A' will display 65. To get character code of a character in a string variable, use operator [ ]. Example: str s="ABC"; out s[0]; out s[1]. To insert an ASCII character into a string using character code, use operator [ ]: str s=" "; s[0]='A' , or format field %c with str.format or other function that supports formatting: str s.format("%c" 'A').