11 T1 = ((1<<(Bit1+1))-1) ^ 0xFF, /* 0000 0000 */
12 Tx = ((1<<(Bitx+1))-1) ^ 0xFF, /* 1000 0000 */
13 T2 = ((1<<(Bit2+1))-1) ^ 0xFF, /* 1100 0000 */
14 T3 = ((1<<(Bit3+1))-1) ^ 0xFF, /* 1110 0000 */
15 T4 = ((1<<(Bit4+1))-1) ^ 0xFF, /* 1111 0000 */
17 Rune1 = (1<<(Bit1+0*Bitx))-1, /* 0000 0000 0111 1111 */
18 Rune2 = (1<<(Bit2+1*Bitx))-1, /* 0000 0111 1111 1111 */
19 Rune3 = (1<<(Bit3+2*Bitx))-1, /* 1111 1111 1111 1111 */
21 Maskx = (1<<Bitx)-1, /* 0011 1111 */
22 Testx = Maskx ^ 0xFF, /* 1100 0000 */
28 chartorune(Rune *rune, char *str)
34 * one character sequence
37 c = *(unsigned char*)str;
44 * two character sequence
47 c1 = *(unsigned char*)(str+1) ^ Tx;
53 l = ((c << Bitx) | c1) & Rune2;
61 * three character sequence
62 * 0800-FFFF => T3 Tx Tx
64 c2 = *(unsigned char*)(str+2) ^ Tx;
68 l = ((((c << Bitx) | c1) << Bitx) | c2) & Rune3;
84 runetochar(char *str, Rune *rune)
89 * one character sequence
90 * 00000-0007F => 00-7F
99 * two character sequence
103 str[0] = T2 | (c >> 1*Bitx);
104 str[1] = Tx | (c & Maskx);
109 * three character sequence
110 * 0800-FFFF => T3 Tx Tx
112 str[0] = T3 | (c >> 2*Bitx);
113 str[1] = Tx | ((c >> 1*Bitx) & Maskx);
114 str[2] = Tx | (c & Maskx);
125 return runetochar(str, &rune);
129 fullrune(char *str, int n)
134 c = *(unsigned char*)str;