Characters (ASCII & Unicode)

💻 Computer Science Years 8–11 Foundation

How characters are stored as number codes using ASCII, and why Unicode is needed for the world's writing systems.

Open this lesson, with practice and a printable worksheet →

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.

Why this matters: Without an agreed character set, a message typed on one computer would turn to gibberish on another. Character encoding is why text files, web pages and messages look the same everywhere — and why emoji and Arabic and Chinese can all live in the same document.
A → 65 → 01000001
Character to code number to binary: 'A' = 65 = 01000001.

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.

CharacterASCII (denary)Binary (8-bit)
space3200100000
'0' (the digit)4800110000
A6501000001
a9701100001

The clever ordering

A = 650 1 0 0 0 0 0 1a = 970 1 1 0 0 0 0 1one bit = the value 3265 + 32 = 97
Capital → lower case flips a single bit (adds 32).

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.

Worked example — encode the word "Hi" in ASCII binary.
H = 72 = 01001000. i = 105 = 01101001.
So "Hi" is stored as 01001000 01101001 — two bytes, one per character.
Hi721050100100001101001
"Hi" = two bytes: H (72) then i (105).

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.

Common mistake: confusing the digit character '5' with the number 5. The character '5' has ASCII code 53, not 5. That is why "12" + "3" as text can give "123" (joining strings) rather than 15 — the computer is handling character codes, not doing sums.
character '5'code 53number 5value 5
The character '5' is code 53, not the number 5.

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.

Get the printable worksheet →
← Hexadecimal → Images & Bitmaps
← Sasta Basta home All subjects