Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 01 · How Computers Work · Bits and switches · about 15 min to read

Play it as a journeyTutor comes with a plan

Every letter in the world: Unicode and UTF-8

Everything Is a Number
Everything Is a Number · Open board

The same switches read as a number, a letter or a colour, depending only on the rule the reader brings.

A customer types the name Zoë into a sign-up form. Your database stores it. The next morning the welcome email says “Zoë”. Nobody changed the data. A different part of the system read the same bytes with a different rule.

Now a harder case. A user types the same name on two phones. Both look like “Zoë” on screen. Your code compares them and says they are different people.

By the end you will be able to write the UTF-8 bytes of any character by hand, say why those two names differ, and explain why one emoji on the screen can be five characters in memory.

The history (optional)

Unicode began as talks in late 1987 between Joe Becker of Xerox, Lee Collins and Mark Davis. Their first draft, in 1988, assumed 16 bits for every character. Unicode version 1.0 came out in October 1991 (source: the Unicode Consortium’s history pages).

UTF-8 came a year later. Rob Pike recalled in a 2003 email that Ken Thompson and he designed it in or around September 1992, at a diner in New Jersey, writing it out on a placemat. They were working on the Plan 9 operating system, and they moved Plan 9 to the new encoding within days. The placemat is Pike’s memory, so treat the story as his account.

Nothing in the lesson depends on this fold.

Before you start. Everything Is a Number (bits & bytes) showed that the same byte can be a number, a letter or a colour, depending on the reader’s rule. It also showed that a byte holds 256 patterns. Numbers for Real (signed ints, overflow, floating point) showed what happens at the edge of a fixed row of bits. Here the fixed row is a byte, and the problem is that 256 patterns cannot name every letter people write.

Lesson 3 of 41 in How Computers Work · Free with an account

Keep reading. It's free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

No card, and chalk sends no email. Google sign-in only.

Start free with Google

In this lesson

  • Code point: every character gets one number
  • UTF-8: how a code point becomes bytes
  • Mojibake: the right bytes read with the wrong rule
  • Normalisation: two spellings of one letter
  • Grapheme cluster: what a reader counts as one character

Terms it explains: code point, UTF-8, mojibake, Normalisation, NFC, NFD, grapheme cluster, NFKC, NFKD, ASCII, binary, bit, byte, endianness, hexadecimal, nibble, RGB, type, Unicode / UTF-8, word size.

Review How Computers Work