Unicode Code Points, UTF-8, and UTF-16 Explained

Every character you type, from a plain letter to an emoji, maps to a Unicode code point β€” here is what that means and how it gets stored as actual bytes.

A code point is a number assigned to a character

Unicode assigns every character a unique code point, written as U+ followed by a hexadecimal number, like U+0041 for the letter "A" or U+1F600 for a grinning-face emoji. The code point identifies the character conceptually, separate from how it gets stored as bytes.

UTF-8 uses one to four bytes per character

UTF-8 is a variable-width encoding: basic ASCII characters take just one byte, while characters outside that range, like accented letters, CJK characters, or emoji, take two to four bytes. This is why a string's byte length is often longer than its visible character count.

UTF-16 usually uses two bytes, but sometimes needs four

UTF-16 encodes most common characters in a single 2-byte unit, but characters outside the Basic Multilingual Plane, including most emoji, require a "surrogate pair" of two 2-byte units instead, which is a common source of bugs when code assumes one unit always equals one character.

HTML numeric entities reference the code point directly

An HTML entity like 😀 or 😀 encodes a character by its decimal or hexadecimal code point number, which is why looking up a character's code point is the first step to writing it as an HTML entity when the literal character can't be typed or displayed directly.

Related characters are grouped into named blocks

Unicode organizes code points into blocks with names like "Basic Latin," "CJK Unified Ideographs," or "Emoticons," grouping related characters into contiguous ranges, which is useful context when identifying roughly what kind of character an unfamiliar code point represents.

Why more than one encoding exists for the same character set

UTF-8, UTF-16, and UTF-32 all represent the same underlying Unicode code points but trade off differently between storage efficiency and processing simplicity. UTF-8 stays compact for English-heavy text and is dominant on the web; UTF-16 is baked into older platform APIs like Windows and Java, which is why both remain in wide use rather than one replacing the other.

Why an emoji sometimes "is" several code points at once

Many modern emoji, like a specific skin-tone thumbs-up or a family emoji, are actually a sequence of multiple code points joined with a special zero-width joiner character, rendered by supporting software as one glyph. This is why some emoji look identical but have a longer underlying code point sequence than others.

Frequently Asked Questions

Why does a string's character count sometimes not match its byte length?

Because encodings like UTF-8 use a variable number of bytes per character β€” a string with only ASCII letters has character count equal to byte count, but adding accented letters, CJK text, or emoji increases the byte length faster than the visible character count.

What is a surrogate pair, in plain terms?

It is a way for UTF-16 to represent a character that doesn't fit in its normal 2-byte unit, by using two special 2-byte units together as a single combined unit. Software that mistakenly treats each half as its own character can split an emoji or rare character in half and corrupt it.