liveBook · Manning

UTF-8

As explained in Grokking Algorithms, Second Edition

UTF-8 is a variable-length character encoding for representing Unicode text using one to four bytes per character.

Before Unicode, character encodings were fragmented: ASCII and ISO-8859-1 covered limited sets, while countries created their own encodings. Unicode brought these efforts under one international standard. section 7.6

Unicode names the characters; UTF-8 is an encoding that stores them. It uses a variable number of bytes—one to four per character—so it can represent text from many languages and remains the most popular Unicode encoding. section 7.6

Choosing an encoding

If a project needs to store text and you are choosing an encoding, UTF-8 is a good default. The surrounding discussion contrasts this broad character coverage with ISO-8859-1, whose fixed 8-bit units provide only 256 possible characters. section 7.6

Keep these distinctions in mind:

  • Unicode is the standard for assigning characters; UTF-8 is one encoding that follows that standard. section 7.6
  • UTF-8 is not the same as a compression algorithm: compression reduces storage bits, while an encoding represents characters. section 7.6

How Grokking Algorithms, Second Edition covers it

How deep it goes
Defines UTF-8 as a one-to-four-byte variable-length encoding but does not explain its byte patterns or decoding mechanics.
Examples
Contrasts UTF-8 with ASCII and ISO-8859-1 while discussing multilingual text and project encoding choices.
What you can do after
Apply it by choosing UTF-8 as a default encoding for a project.
How it connects
Connects UTF-8 with Unicode, character encoding, ASCII, ISO-8859-1, and compression algorithms.

Also explained in

Compare how 11 books explain UTF-8 →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Algorithms, Second Edition. The section links point to the parts of the book it draws on.