Character Set - UTF8

1 - About

utf version 8 bytes.

3 - Category

UTF-8 bytes are divided in “waterproof” categories as follows:

3.1 - Single Byte

Bytes 0x00 to 0x7F are single bytes, they each represent a single codepoint in the exact same format as in Latin-1 or 7-bit US-ASCII.

3.2 - Multibyte sequence Byte

Bytes 0xC0 to (currently) 0xF4 or 0xFD are header bytes in a multibyte sequence. Such a byte MUST be the first byte of its sequence and the number of “one” bits above the topmost “zero” bit indicates the number of bytes (including this one) in the whole sequence.

3.2.2 - Trailer

Bytes 0x80 to 0xBF are trailer bytes in a multi-byte sequence. They can be any byte in the sequence except the first.

3.2.3 - Payload

In the bytes of a multi-byte sequence, all bits after the topmost “zero” bit in each byte constitute the payload: they are data bits, and in UTF-8 the most significant bits always come first.

3.3 - Invalid

Bytes 0xFE and 0xFF are always invalid anywhere in UTF-8 text.

The Unicode code space had originally been foreseen as ranging from U+0000 to U+7FFFFFFF but the current standards say that no codepoints above U+10FFFD will ever be valid; also, codepoints whose hex representation is xxFFFE or xxFFFF (where xx is anything) have been expressly designated as invalid, never to be used.

3.4 - Note

Note that some hanzi are above U+20000; the UTF-8 code for them consists of four bytes, not three: e.g. 𠄣 = U+20123 = UTF-8 0xF0 0xA0 0x84 0xA3 = %F0%A0%84%A3 in "percent-escaped" HTTP coding

4 - Translation of a UTF-8 Multibyte sequence to Unicode

4.1 - Example 1

Problem: translation of the 3 Byte sequences e9 a6 ac into unicode.

Steps:

Result: Concatenated payload bits 1001.1001.1010.1100 binary, or U+99AC

4.2 - Example 2

Problem: translation of the 3 Byte sequences e2 80 93 into unicode.

Steps:

Result: Concatenated payload bits 0010.0000.0001.0011 binary, or U+2013

5 - Documentation / Reference

data/type/text/utf8.txt · Last modified: 2018/12/07 13:04 by gerardnico