Here is a code point: U+091D. The symbol it represents in UTF-8 is . In hex the symbol requires three bytes: e0 a4 9d. But it looks like the number 091D requires two bytes. So why do we need three bytes to encode the symbol? Probably due tothe restriction of the Unicode code-space to 21-bit values in 2003Please see the beginning of the description section. OK, but why did they restrict the code-space to 21 bits? I converted e0 a4 9d to binary, and the result is 11100000 10100100 10011101Then I converted 091D to binary and got00001001 00011101The two binary results seems to have little in common. So how did 091D become e0 a4 9d?
Understanding the binary and hexadecimal representations of UTF-8
encoding scheme
Where the 21 bits come from: The idea of unicode is based on the Universal Coded Character Sets (short UCS). It's a concept for a 31bit character set ordered as a 4D hypercube where the first three dimensions use 8bit and the fourth uses 7bit. Per row there are $2^8$ characters. Per plane there are $2^8$ rows $=65.536$ characters. Per cube there are $2^8$ planes and there are $2^7$ cubes. Unicode decided to just use a mere 17 planes (the code space 0 - 10FFFF), which corresponds to the 21bits.UTF-8 is a variable length encoding mostly used for encoding unicode. Variable length means that it uses 1 to 4 byte to represent a certain code point, depending on its number of significant bits.The scheme looks as following:1 byte: At most 7 significant bits. From U+0000 to U+007F.Scheme: 0xxxxxxx.2 bytes: At most 11 significant bits. From U+0080 to U+07FF.Scheme: 110xxxxx 10xxxxxx 3 bytes: At most 16 significant bits. From U+0800 to U+FFFF.Scheme: 1110xxxx 10xxxxxx 10xxxxxx 4 bytes: At most 21 significant bits. From U+10000 to U+10FFFF.Scheme: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxxIn your example you have 12 significant bits and therefore the 3 bytes used for encoding.For further details see https://en.wikipedia.org/wiki/UTF-8.