UTF-8 (source code)
= UTF-8
{c}
<UTF-8> encodes each <Unicode scalar value> in one to four <bytes>. <ASCII> values use one <byte>; non-ASCII leading <bytes> announce the sequence length, and continuation <bytes> begin with the <bit> pattern `10`. This makes <byte> boundaries identifiable without using a separate delimiter after every character.<UTF-8, a transformation format of ISO 10646 by Francois Yergeau>[RFC3629, §§3–4]{ref}
For example, `U+00E9` is encoded as <hexadecimal> `C3 A9`, while `U+1F600` uses `F0 9F 98 80`. Valid decoding excludes surrogate values, values above `U+10FFFF` and overlong encodings of smaller values. A <byte> offset therefore need not be a code-point boundary, and a code-point boundary need not be a <grapheme cluster> boundary. Correct slicing and validation must <state> which unit they operate on.
Back to article page