Unicode Detective
Every character has a secret number.
Your mission
A mystery for you, detective: the computer stores your messages using nothing but numbers. Type English letters, Chinese characters, Arabic letters or emoji and uncover the code behind each one: its Unicode code point and the UTF-8 bytes it takes up. Then solve the cases.
Explore
Investigate one of each kind of character: tap its card, or type your own.
Every character you type is secretly stored as a number. Tap a character card to investigate it, or type something of your own.
0 of 4 kinds investigated
Experiment
Solve all six cases in the casebook.
The casebook
Solve each case by typing (or tapping) the right characters. They tick themselves off.
0 of 6 cases solved
Challenge
No live decoder this time! Use what you found out to crack six case files.
Clue board
What you found out so far.
- 1 byteASCII: English letters, digits, spaces, punctuation
- 2 bytesAccented letters (é) and Arabic letters
- 3 bytesChinese characters (and €)
- 4 bytesEmoji
A = 65 and a = 97. Place values for one byte: 128, 64, 32, 16, 8, 4, 2, 1.
Crack all 6 case files to continue.
Understand
Here is what the detective work was showing you, in the words you need for the exam.
Every character is a number
A computer can only store binary, so text is stored by giving every character a numeric code. The list of characters and their codes is called a character set.
ASCII was one of the first. It has 128 codes (0 to 127), enough for English letters, digits, punctuation and a few control codes. Each character is stored in one 8-bit byte.
a = 97 = 01100001 and A = 65 = 01000001. Small letters are always 32 more than their capitals.
Why we need Unicode
128 codes leave no room for Chinese (thousands of characters), Arabic, accented letters or emoji. ASCII cannot represent Chinese.
Unicode is a much bigger character set. It covers the writing systems of the world, so English and Chinese (and Arabic, and emoji) can sit in the same text. Each character gets a code point, written U+ and a hexadecimal number.
A = U+0041, 你 = U+4F60, م = U+0645, 😀 = U+1F600. The first 128 code points are the same as ASCII.
UTF-8: turning code points into bytes
UTF-8 is the most common way to store Unicode. It uses 1 to 4 bytes per character: small code points get fewer bytes, big ones get more. English text in UTF-8 is byte-for-byte identical to ASCII.
| Code points | Bytes | Examples |
|---|---|---|
| U+0000 to U+007F | 1 | A z 7 ? (ASCII) |
| U+0080 to U+07FF | 2 | é ñ α م |
| U+0800 to U+FFFF | 3 | 你 好 € |
| U+10000 and up | 4 | 😀 🚀 |
Words to know
- Character set
- A list of characters, each with its own numeric code.
- ASCII
- 128 codes for English letters, digits and symbols. One byte per character.
- Unicode
- A character set for the writing systems of the whole world, plus emoji.
- Code point
- A character's number in Unicode, such as U+4F60 for 你.
- UTF-8
- Stores each code point in 1, 2, 3 or 4 bytes.
Exam tip
In 8-bit ASCII, every character is 1 byte = 8 bits, so count the characters (spaces too!) and multiply by 8. "Aa" is 2 characters, so it needs 2 × 8 = 16 bits. To write a letter in binary, use the place values: a = 97 = 64 + 32 + 1 = 01100001.