ASCII (American Standard Code for Information Interchange) uses 128 numbers to represent the characters of the alphabet, the digits, punctuation characters, and some special characters that are used to control printers, terminals, and other computer devices. The 128 values are numbered beginning with zero, so the numbers used are 0 through 127.
The ASCII character set includes all the digits, the upper- and lowercase letters of the alphabet, and punctuation characters. All the printable characters (letters, digits, and punctuation) have values between 32 and 126. The values 0 through 31 and 127 are used for control characters.
Table B.1 is a brief ASCII chart with the decimal value of each entry, and its ASCII name or character. Several of the ASCII codes represent nonprintable characters, and these are represented by their names. You might be familiar with some of these.
0 | NUL | 32 | SP | 64 | @ | 96 | ` |
1 | SOH | 33 | ! | 65 | A | 97 | a |
2 | STX | 34 | " | 66 | B | 98 | b |
3 | ETX | 35 | # | 67 | C | 99 | c |
4 | EOT | 36 | $ | 68 | D | 100 | d |
5 | ENQ | 37 | % | 69 | E | 101 | e |
6 | ACK | 38 | & | 70 | F | 102 | f |
7 | BEL | 39 | ` | 71 | G | 103 | g |
8 | BS | 40 | ( | 72 | H | 104 | h |
9 | HT | 41 | ) | 73 | I | 105 | i |
10 | LF | 42 | * | 74 | J | 106 | j |
11 | VT | 43 | + | 75 | K | 107 | k |
12 | FF | 44 | , | 76 | L | 108 | l |
13 | CR | 45 | - | 77 | M | 109 | m |
14 | SO | 46 | . | 78 | N | 110 | n |
15 | SI | 47 | / | 79 | O | 111 | o |
16 | DLE | 48 | 0 | 80 | P | 112 | p |
17 | DC1 | 49 | 1 | 81 | Q | 113 | q |
18 | DC2 | 50 | 2 | 82 | R | 114 | r |
19 | DC3 | 51 | 3 | 83 | S | 115 | s |
20 | DC4 | 52 | 4 | 84 | T | 116 | t |
21 | NAK | 53 | 5 | 85 | U | 117 | u |
22 | SYN | 54 | 6 | 86 | V | 118 | v |
23 | ETB | 55 | 7 | 87 | W | 119 | w |
24 | CAN | 56 | 8 | 88 | X | 120 | x |
25 | EM | 57 | 9 | 89 | Y | 121 | y |
26 | SUB | 58 | : | 90 | Z | 122 | z |
27 | ESC | 59 | ; | 91 | [ | 123 | { |
28 | FS | 60 | < | 92 | \ | 124 | | |
29 | GS | 61 | = | 93 | ] | 125 | } |
30 | RS | 62 | > | 94 | ^ | 126 | ~ |
31 | US | 63 | ? | 95 | _ | 127 | DEL |
A control character is a single character that can be sent to a computer device, such as a printer or monitor, that controls the behavior of the device (rather than printing an actual character). For example, the value 13 (CR) is a carriage return. This value sent to a printer causes the print head to return to column 1. A CR also is the code usually sent by the Return or Enter key on the keyboard. Value 7 (BEL), when sent by the computer to the terminal, usually causes a beep or rings an alarm.
The following are some of the other control characters: HT (Horizontal Tab) value 9. This character, sent to a printer or a screen, causes the cursor or print head to advance to the next column. SO (Shift Out) and SI (Shift In), values 14 and 15. Many printers are set up with two built-in fonts. Sending an SI causes the printer to shift to the second font. Sending an SO causes the printer to shift back to the first font. The values from 32 through 126 are printable characters. Value 32 (SP) is a space. Whether a space is actually a "printable" character is a debatable issue. A space does not usually put ink on the paper; instead, it places a character containing no image. Some printers create this by simply advancing the print head one position.
The characters in the range below 32 are used extensively in telecommunications. For example, 02 and 03 (STX and ETX) are often used at the start and end of a block of transmitted information. 06 and 21 (ACK and NAK) are often used by a receiving computer to signal acknowledgement (ACK for well-received) or a negative acknowledgement (NAK for not well-received, please retransmit).
For a detailed and excellent description of ASCII, read The C Programmer's Guide to Serial Communications, Second Edition, by Joe Campbell (Sams Publishing). Chapter 1 on ASCII alone makes the book worth the cover price.
© Copyright, Macmillan Computer Publishing. All rights reserved.