ASCII Codes

There was a time when every book on programming had a table of ASCII codes as an appendix. The ASCII codes (American Standard Code for Information Interchange) used the numbers from 32 to 127 to represent characters of the English alphabet. These 96 codes corresponded to the upper and lower case alphabet, the numerals, and the most useful symbols for punctuation.

The tables were always included in the books because it was almost impossible to do much in the way of programming without using ASCII codes either in decimal or hexadecimal form. Modern high-level languages do not rely on these codes as heavily but there are still times when you might use them to:

  • Read information from a file stored in an unusual format
  • Encrypt or decrypt a password read as a series of bytes
  • Produce a character which is not easily available on your keyboard
  • Produce a character (typically a quote) which would cause a syntax error if typed explicitly.

Visual FoxPro and Access both use the same syntax for the functions which manipulate ASCII codes:

Asc(number) returns the character with that ASCII code.

Chr(character) returns the ASCII code of that character.

Table of ASCII codes

This table lists the decimal and hexadecimal codes for the characters. The Asc() and Chr() functions both work with decimal values but you might need to be able to recognise the hexadecimal values if you are using low-level techniques when reading from a text file.

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