unicode - C++ bit manipulation -
i trying extract character value utf-8 format. suppose have 2 characters, , extract 5 bits first character => 10111 , 6 bits character => 010000
so
ch1 = 10111; ch2 = 010000;
how combine them form 10111010000 , output hex 0x5d0? need shift or there easier way this, because checking documentation write
appear able read characters sequentially, there similar function this? also, appears need char buffer since 10111010000 11 bits long. know how go this?
you need use shifting, plus |
or |=
operator.
unsigned int ch3 = (ch1 << 6) | ch2; // ch3 = 0000010111010000
i'm assuming here unsigned int
16 bits. mileage may vary.
Comments
Post a Comment