Reputation: 39
I want convert U+0780 to UTF-8.
Table:
U+00000000 - U+0000007F 0xxxxxxx
U+00000080 - U+000007FF 110xxxxx 10xxxxxx
U+00000800 - U+0000FFFF 1110xxxx 10xxxxxx 10xxxxxx
U+00010000 - U+001FFFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
Convert 0780 from hex to binary.
00000111 10000000
I choose second line of table
110xxxxx 10xxxxxx
How I fill bits to 00000111 10000000
to template 110xxxxx 10xxxxxx
Upvotes: 0
Views: 107
Reputation: 31153
The template is 110xxxxx 10xxxxxx
, so there are 11 bits available.
Take the 11 used bits of the character: 111 10000000
, put them in the template in that order, left to right, five leftmost bits 11110
for the first byte and the remaining six bits 000000
for the second byte.
You get: 11011110 10000000
.
Upvotes: 2