Why is the length of the some characters e.g. the following 'ᨒ' 3 when it should be 2
ᨒ U+1a12
1a12 means 6674
2^16 is 65536 so 6674 should take only 2 bytes and not three
|
Why is the length of the some characters e.g. the following 'ᨒ' 3 when it should be 2 ᨒ U+1a12 1a12 means 6674 2^16 is 65536 so 6674 should take only 2 bytes and not three |
|||||
|
|
The code 6674 requires at least 13 binary bits to encode. UTF-8 requires 5 prefix bits to indicate that a 2-byte encoded Unicode value isn't just two regular old 7-bit ASCII characters instead. 13+5 = 18, which is more than can fit in 16 bits or 2 bytes. So it takes 3 bytes to encode (adding 2 more Unicode prefix bits). |
|||
|
|
|
There are 3 encodings of unicode: UTF-8, UTF-16, UTF-32 In UTF-8 it takes 3 bytes: UTF-16 would take 2 bytes: http://en.wikipedia.org/wiki/UTF-8 UTF-8 character length from Wikipedia page:
|
|||||||||||||||
|