4 static int utf8_encode(unsigned char c[4], unsigned uc)
6 unsigned char uc1, uc2;
10 if ((uc2 & 0xf8) == 0xd8) {
19 c[0] = 0xe0 | (uc2>>4);
20 c[1] = 0x80 | ((uc2&0xF)<<2) | (uc1>>6);
21 c[2] = 0x80 | (uc1&0x3f);
26 if (uc2 | (uc1 & 0x80)) {
27 c[0] = 0xc0 | (uc2<<2) | (uc1>>6);
28 c[1] = 0x80 | (uc1&0x3f);
39 int main(int argc, char *argv[])
44 for (i=1;i<argc;i++) {
48 c = strtol(argv[i], NULL, 16);
50 int len = utf8_encode(s, c);