American Standard Code for Information Interchange (ASCII)
1. Definition and History
ASCII (American Standard Code for Information Interchange, pronounced "as-key") is a character encoding standard published in 1963/1968 that maps each character to a unique 7-bit binary code, giving characters — 95 printable characters plus 33 control characters. It was standardised to make text portable between different computers and teletypes, which previously used their own incompatible codes (Baudot, EBCDIC).
In memory ASCII is normally stored in a full byte (8 bits); the MSB is either left 0 or used as a parity bit.
2. Structure of the ASCII Table
| Range (decimal) | Range (hex) | Content | Examples |
|---|---|---|---|
| 0-31 | 00-1F | Control characters (non-printable) | NUL(0), BEL(7), TAB(9), LF(10), CR(13), ESC(27) |
| 32 | 20 | Space | — |
| 33-47 | 21-2F | Punctuation | ! " # $ % & ' ( ) * + , - . / |
| 48-57 | 30-39 | Digits 0-9 (contiguous) | '0' = 48 … '9' = 57 |
| 58-64 | 3A-40 | Punctuation | : ; < = > ? @ |
| 65-90 | 41-5A | Uppercase A-Z (contiguous) | 'A' = 65 … 'Z' = 90 |
| 91-96 | 5B-60 | Punctuation | [ \ ] ^ _ |
| 97-122 | 61-7A | Lowercase a-z (contiguous) | 'a' = 97 … 'z' = 122 |
| 123-126 | 7B-7E | Punctuation | { | } ~ |
| 127 | 7F | DEL | Delete |
3. Codes Worth Memorising
| Character | Decimal | Binary (7-bit) | Hex |
|---|---|---|---|
| NUL | 0 | 000 0000 | 00 |
| TAB | 9 | 000 1001 | 09 |
| LF (newline) | 10 | 000 1010 | 0A |
| CR | 13 | 000 1101 | 0D |
| Space | 32 | 010 0000 | 20 |
| '0' | 48 | 011 0000 | 30 |
| '9' | 57 | 011 1001 | 39 |
| 'A' | 65 | 100 0001 | 41 |
| 'Z' | 90 | 101 1010 | 5A |
| 'a' | 97 | 110 0001 | 61 |
| 'z' | 122 | 111 1010 | 7A |
| DEL | 127 | 111 1111 | 7F |
4. Why the Arrangement Matters
The designers deliberately placed related characters in contiguous blocks, which makes common operations cheap:
- Case conversion — uppercase and lowercase letters differ by exactly 32 (2⁵, i.e. one bit): to convert 'a' to 'A', subtract 32 (clear bit 5); to convert 'A' to 'a', add 32.
- Digit to number — the numeric value of a digit character is
code - 48:'7' - 48 = 7, so converting a typed digit to an integer is one subtraction. - Ordering and sorting — digits sort before uppercase letters, which sort before lowercase, so simple numeric comparison on codes gives alphabetic order (with the caveat that all uppercase letters precede all lowercase ones).
5. Example: Encoding "YES"
| Character | ASCII decimal | Binary |
|---|---|---|
| Y | 89 | 101 1001 |
| E | 69 | 100 0101 |
| S | 83 | 101 0011 |
"YES" is stored (with a possible parity bit) as 59 45 53 in hex.
6. Control Characters, Parity and Framing
- Control characters were designed for terminals: LF (line feed), CR (carriage return), BS (backspace), BEL (bell), ESC (escape sequence introducer), and NUL used as a string terminator in C.
- In the 8-bit extended ASCII used inside memory, the 8th bit is frequently a parity bit for error detection: even parity sets the bit so that the total number of 1s is even (
'A' = 100 0001has two 1s → parity bit 0;'C' = 100 0011has three 1s → parity bit 1 for even parity). A single-bit error changes the parity and is detected. - Serial transmission adds start and stop bits around the 7-bit code; this 10-bit group is one "character frame".
7. Extended ASCII (8-bit variants)
Using all 8 bits gives 256 codes, and several incompatible extensions filled the upper 128: IBM CP437 (box-drawing, block graphics), Windows-1252, ISO-8859-1 (Latin-1) (accented European letters, currency). Because the upper half was never standardised, the same byte shows as é, Θ or a box character depending on the code page — the classic source of "mojibake" garbled text.
8. Limitations that Led to Unicode
- Only 128 (or 256) characters are representable — no Indian scripts (Devanagari, Tamil), Chinese/Japanese/Korean, Arabic, emoji.
- Different vendors' extensions clashed, so text was not portable across locales.
- No built-in way to represent many mathematical symbols, combining accents or bidirectional text.
These limits motivated Unicode (next topic), which keeps ASCII's first 128 code points identical so that existing English text remains valid.
9. Exam Points
- Full form of ASCII; how many characters does it represent and how many bits are used? — 3 marks, very frequent.
- Give the ASCII codes of 'A', 'a', '0', '9', space and newline — 3 marks.
- Explain how case conversion and digit-to-number conversion exploit ASCII ordering — 5 marks.
- What is extended ASCII? Why is it non-standard? — 3 marks.
- How is a character stored in memory (7-bit code + parity bit)? — 3-5 marks.
- Draw the ASCII table structure (control, digits, upper, lower ranges) — 5 marks.