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. Characters in ANSI character sets consist of single byte. Most charactes in the Unicode character set consist of two bytes. Characters in range 0 to 127, also called ASCII characters, are the same in all character sets. They are listed in the tables below.
Most of characters in range 0 to 31 are rarely used. Often used are these characters:
| Code | Char |
| 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 |
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.
Characters in the Unicode character set are the same on all computers. Note that not all fonts support all characters.
QM uses the Unicode character set if the checkbox is checked in Options. Otherwise it uses the default ANSI character set.
In a macro, to get character code of an ANSI 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 [ ]. This example displays character codes of first and second characters in str variable s: out s[0]; out s[1]. To insert an ANSI 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') ). However you cannot simply insert Unicode characters. The second macro in the examples (below) shows how to do it. Also, in Unicode mode you cannot simply insert ANSI characters with codes >=128, because the string will not be valid UTF-8. The first macro in the examples shows how to do it.
displays ANSI character codes and characters out int i for i 1 256 out "%i %s" i AnsiCharToString(i)
/ function~ ch [codepage] Converts ANSI character to string. In Unicode mode the string will be UTF-8. if(ch&0xffffff00) end ES_BADARG str s if(_unicode) lpstr ss=+&ch s.unicode(ss codepage) s.ansi else s=" " s[0]=ch ret s
displays Unicode character codes, characters, and number of UTF-8 bytes when QM is running in Unicode mode out int i for i 1 0x10000 str s=UnicodeCharToString(i) out "%i %s [%i]" i s s.len
/ function~ ch Converts Unicode character to string. In Unicode mode the string will be UTF-8. Otherwise it will be ANSI, and Unicode characters that cannot be translated to ANSI will be converted to ?. if(ch&0xffff0000) end ES_BADARG str s lpstr ss=+&ch s.ansi(ss) ret s