It's probably not possible to do it all that much faster than strlen(utf8_to_string( X[..offset])).
The only thing you can skip is the string generation. It's always O(n) to go from byte index to character index in UTF-8.
/ Per Hedbor ()
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