int ch=0; while(p<offset) switch(str[p++]) { case 0xc0..0xdf: p+=1; break; case 0xe0..0xef: p+=2; break; case 0xf0..0xf7: p+=3; break; case 0xf8..0xfb: p+=4; break; case 0xfc..0xfd: p+=5; break; case 0xfe..0xff: error("Invalid UTF-8!\n"); }
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-09-24 12:20: Subject: utf8_char_index
I need a hack for utf8 conversion, utf8 string byte offset <-> character number
Anyone that knows enough utf8 and feels up to it?
/ Mirar