These are the functions I use now:
array(int)|int utf8_byte_index_to_char_number(array(int)|int c,string utf8) { if (arrayp(c)) return map(c,utf8_byte_index_to_char_number,utf8); return c && strlen(utf8_to_string(utf8[..c-1])); }
array(int)|int char_number_to_utf8_byte_index(array(int)|int c,string wide) { if (arrayp(c)) return map(c,char_number_to_utf8_byte_index,wide); return c && strlen(string_to_utf8(wide[..c-1])); }
...if someone feels like writing them in C and adding them to String or something it would probably not be horribly bad. :)
It might encourage people to use UTF8 internally, and that _would_ be horribly bad... :-/
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-09-24 12:45: Subject: utf8_char_index
These are the functions I use now:
array(int)|int utf8_byte_index_to_char_number(array(int)|int c,string utf8) { if (arrayp(c)) return map(c,utf8_byte_index_to_char_number,utf8); return c && strlen(utf8_to_string(utf8[..c-1])); }
array(int)|int char_number_to_utf8_byte_index(array(int)|int c,string wide) { if (arrayp(c)) return map(c,char_number_to_utf8_byte_index,wide); return c && strlen(string_to_utf8(wide[..c-1])); }
...if someone feels like writing them in C and adding them to String or something it would probably not be horribly bad. :)
/ Mirar
We don't have to document them. :-)
If you want, we could hide them inside _Regexp_PCRE. :)
/ Mirar
Previous text:
2003-09-24 12:47: Subject: utf8_char_index
It might encourage people to use UTF8 internally, and that _would_ be horribly bad... :-/
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
pike-devel@lists.lysator.liu.se