Year 8 · Spring 1

Representations: from clay to silicon · Lesson 4 of 5

ASCII and Unicode

PracticalTopic 4 Representing text

Year 8 · Representations: from clay to silicon · Lesson 4 of 5

You will learn to

  • Explain why every computer must use the same character set.
  • Convert characters to ASCII codes and back, using A = 65, a = 97 and the digit 0 = 48.
  • Explain why the code for B is one more than the code for A.
  • Explain why Unicode was needed, and that its first 128 codes are the same as ASCII.

Year 8 · Representations: from clay to silicon · Lesson 4 of 5

Success criteria

You have got it when you can say:

  • I can write my name as ASCII codes with the ASCII toy.
  • I can work out the code for any capital letter, starting from A = 65.
  • I can work out how many bytes a word takes at one byte per character.

Year 8 · Representations: from clay to silicon · Lesson 4 of 5

Retrieval starter

Questions from before. Write your answers, then show them.

  1. Last lesson

    1111 in hex is…

    A FB EC 15

    A. F

  2. Last unit

    404 means…

    A The server crashedB Not foundC OK

    B. Not found

  3. Earlier this year

    Shifting a binary number one place right…

    A Doubles itB Adds 1C Halves it

    C. Halves it

Year 8 · Representations: from clay to silicon · Lesson 4 of 5

Key words

ASCII
7-bit character set with 128 characters. A = 65.
Unicode
Character set for every writing system, plus emoji.
Character set
The agreed list of characters and the number for each.
UTF-8
The usual way Unicode is stored. 1 byte for the old ASCII characters (so old files still work), 2 bytes for ñ or é, 3 for €, 4 for emoji.

The explanation · step 1 of 3 · part 1 of 2

ASCII

ASCII (said 'ass-key') was agreed in the 1960s.

  • 7 bits per character → 2⁷ = 128 characters.
  • Covers A–Z, a–z, 0–9, punctuation, space, and invisible control characters like 'new line'.
  • 'Extended ASCII' uses 8 bits for 128 more, like é and ñ.

The explanation · step 1 of 3 · part 2 of 2

ASCII (continued)

CharacterCodeBinary
A6501000001
B6601000010
Z9001011010
a9701100001
0 (the digit)4800110000
space3200100000

The explanation · step 2 of 3

Worked example: storing 'Hi'

  1. Look up H → 72. Look up i → 105.
  2. 72 in binary: 64 + 8 → 01001000.
  3. 105 in binary: 64 + 32 + 8 + 1 → 01101001.
  4. The computer stores 01001000 01101001.
  5. Size: 2 characters × 8 bits = 16 bits = 2 bytes.

The explanation · step 2 of 3

The maths: How big is some text?

The explanation · step 3 of 3

Unicode: when 256 isn't enough

ASCII has no room for Chinese, Arabic, Hindi, Greek or emoji. Unicode is one giant list for every writing system.

  • Room for over a million characters. About 150,000 used so far, including emoji.
  • Its first 128 codes are the same as ASCII, so A is still 65.
  • UTF-8 stores ASCII in 1 byte and other characters in 2 to 4 bytes.

Year 8 · Representations: from clay to silicon · Lesson 4 of 5

Try it: Type some text

Year 8 · Representations: from clay to silicon · Lesson 4 of 5

Quick quiz · 1 of 3

A web page shows 'España'. Why?

  1. A The file is broken
  2. B Spanish isn't in Unicode
  3. C UTF-8 bytes are being read with an old 8-bit table

C. UTF-8 bytes are being read with an old 8-bit table

ñ is 2 bytes in UTF-8. An old table reads each byte as its own character: Ã and ±.

Year 8 · Representations: from clay to silicon · Lesson 4 of 5

Quick quiz · 2 of 3

If A = 65, what is D?

  1. A 68
  2. B 67
  3. C 69

A. 68

A 65, B 66, C 67, D 68. Letters run in order.

Year 8 · Representations: from clay to silicon · Lesson 4 of 5

Quick quiz · 3 of 3

How many characters can 7-bit ASCII represent?

  1. A 127
  2. B 128
  3. C 256

B. 128

2⁷ = 128 patterns, numbered 0 to 127.

Year 8 · Representations: from clay to silicon · Lesson 4 of 5

Exit ticket

Answer on paper before you go. Then check.

  1. 'Cat' in 8-bit ASCII takes…

    A 8 bitsB 24 bitsC 3 bits

    B. 24 bits 3 characters × 8 bits = 24 bits (3 bytes).

  2. A = 65 and a = 97. Which bit is different between them?

    A The 32s bitB The 128s bitC The 1s bit

    A. The 32s bit 97 − 65 = 32. Only the 32s column changes: 01000001 → 01100001.