Bookmarks

UTF-8 — UTF-8 encoding

Unicode Transformation Format, 8-bit

A way of writing Unicode characters as bytes: each character takes from one to four bytes, and the first 128 values match ASCII.

Also: Unicode, UTF-8, Unicode encoding

checked 9 Nov

All terms

A computer stores text as numbers, and what the reader sees depends on the agreement about which number stands for which letter. UTF-8 has become that agreement for the whole internet: according to W3Techs in November 2026, it is used by 99.1% of websites. That is why modern languages, protocols and databases are designed around it by default.

Unicode and encodings

Unicode is not an encoding but a single catalogue of characters: each one has a permanent number, a code point (for example, U+0416 for the Cyrillic letter Zhe). An encoding is a way of writing those numbers as bytes. Unicode has several: UTF-8, UTF-16, UTF-32. They differ in the length of the code unit: 8, 16 or 32 bits.

PropertyUTF-8UTF-16UTF-32
Bytes per character (Latin)12 or 44
Bytes per character (Cyrillic)224
Bytes per character (emoji)444
Byte ordernoneplatform-dependentplatform-dependent
Most common inweb, Unix, JSONJava, Windowsrare, internal formats

How the bytes are structured

Characters numbered up to 127 (Latin letters, digits, punctuation) take one byte, exactly as in ASCII. So text made of English letters and digits is byte-for-byte identical to ASCII in UTF-8. All other characters are encoded in two, three or four bytes: the first byte gives the length of the sequence, and the rest start with the bits 10.

Code point rangeBytes in UTF-8Example
U+0000–U+007F0xxxxxxxA = 41
U+0080–U+07FF110xxxxx 10xxxxxxCyrillic Zhe = D0 96
U+0800–U+FFFF1110xxxx 10xxxxxx 10xxxxxx€ = E2 82 AC
U+10000–U+10FFFF11110xxx 10xxxxxx 10xxxxxx 10xxxxxx😊 = F0 9F 98 8A

Why UTF-8 won

  • ASCII compatibility: old programs and parsers that work with ASCII do not break on UTF-8.
  • Self-synchronisation: from any byte, a decoder can see whether it starts a character or continues one, and after an error it resumes at the next character.
  • No byte-order problem: UTF-16 and UTF-32 need a BOM or an explicit platform byte order, UTF-8 does not.
  • Compact for Latin text: JSON, HTML and source code, which are mostly ASCII, barely grow in size.

UTF-8 was devised by Ken Thompson in September 1992, to criteria set out by Rob Pike, for the Plan 9 operating system. In 2003 the IETF published RFC 3629, which limited the encoding to the range up to U+10FFFF and fixed the UTF-8 label in the IANA registry. The Encoding Standard requires new protocols and formats to use only UTF-8, and tells HTML and XML authors to encode documents in UTF-8 and label them utf-8; in HTML, the string utf-8 is the only valid value of the charset attribute on the meta element.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • HTTPHTTP

    HTTP carries data over the network, while UTF-8 turns text into bytes: an encoding is responsible only for how characters are written as numbers.