Programming foundations

Stage 3 · Lesson 2 of 9

Text encodings: ASCII, Unicode and UTF-8

How computers run your code

Text is stored as numbers too. maps 128 characters to numbers, one byte each; for example, A is 65. Unicode gives every character in every writing system its own number, called a code point.

UTF-8 is the encoding, the storage format, that saves those code points in 1 to 4 bytes while leaving plain ASCII unchanged. UTF-8 is the default on the web and in most files you will read. Bugs appear when a program reads bytes with the wrong encoding, which produces garbled text like "café".

They also appear when code assumes one character is one byte: "é" takes 2 bytes in UTF-8 and most emoji take 4. Always name the encoding when you open a file.

A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

Keep handy

  • Quick explanations of OS basics like processes and memory when a lecture skips a step

Also worth your time

  • Everything from a key press to a rendered page; read it after this stage

Mark this stage as not done?