A computer stores only numbers, yet your screen is full of letters. The trick is an agreed code: every character is given a number, and everyone's machine uses the same list. Press A and the keyboard sends 65; the screen looks up 65 and draws an A. Text is just numbers wearing a costume.
ASCII — the original code
ASCII (American Standard Code for Information Interchange) gives each common character a number using 7 bits, so it can represent 27 = 128 characters: the English letters (upper and lower case), digits, punctuation and some invisible control codes. In practice each character is stored in one byte, with a spare leading 0.
| Character | ASCII (denary) | Binary (8-bit) |
|---|---|---|
| space | 32 | 00100000 |
| '0' (the digit) | 48 | 00110000 |
| A | 65 | 01000001 |
| a | 97 | 01100001 |
The clever ordering
The codes are not random. Capital letters run A=65, B=66, C=67 in order, and lower-case runs a=97, b=98 in step. So the gap between any capital and its small version is always 32. Think of it as two matching rows on a shelf, one exactly 32 places along from the other — flip a single bit and you change the case.
H = 72 = 01001000. i = 105 = 01101001.
So "Hi" is stored as 01001000 01101001 — two bytes, one per character.
Unicode — room for every language
128 characters is nowhere near enough for the world's writing systems, let alone emoji. Unicode solves this by using far more bits, giving space for over a million characters — Arabic, Chinese, Greek, symbols and 😀 all included. Its first 128 codes are identical to ASCII, so old text still works. The cost is that each character can take more than one byte, so Unicode text can be larger.
Tip: to switch a capital to lower case, add 32 to its ASCII code (A 65 → a 97); to go the other way, subtract 32. Remembering that single fact answers a whole family of exam questions.