TwiddleLab / Code / How Computers Store Everything
Letters Are Numbers
What you will learn
- Every character has a number, its code: A is 65, a is 97.
- ASCII gave codes to English letters, digits and signs. Unicode gives one to every character, about 150 000 of them, emoji too.
- Capitals and small letters are 32 apart.
- In UTF-8 a character takes 1 to 4 bytes: English letters 1, emoji 4.
How the lesson goes
When you text hi, what actually travels to your friend's phone?
Type it and watch the wire.
Each lamp pattern is a number. A is 65, B is 66.
Give C, H and Z their numbers.
A message arrives as numbers. Decode it one by one.
Before each Step, tap the letter you expect.
Character codes.
A character code is the number a computer stores for a character. Typing sends the code, the screen draws the letter.
ASCII (1963) numbered English letters, digits and signs: A is 65, a is 97, the digit 0 is 48, a space is 32. Each fits in one byte.
Unicode gives a number, a code point, to every character in every language, about 150 000 of them: Ж is 1046, 😂 is 128514. UTF-8 stores each one in 1 to 4 bytes.
Type your nickname and see its bytes.
2 to 8 characters. You'll send it to a friend at the end.
Here is your nickname in capitals. Turn it into small letters.
The slider adds the same number to every code.
Chatbots famously miscount the r's in strawberry. Why?
Count them yourself, then see what the chatbot gets.
Decode relay: five messages, as fast as you can.
Type each letter the numbers stand for.
How many bytes does each character take in UTF-8?
Drag each one into its jar.
Send your nickname to a friend.
Add an emoji if you like, then press Send.
Previous lesson: Bytes and Overflow · Next lesson: Pixels and Colors · Part of the course: How Computers Store Everything
Lessons are interactive and need JavaScript. Turn it on to play them.