Actually, I wish to do it on a whole list of numbers (at least 2), unfortunately unsorted. That could be optimized.
It's the exec() function in pcre that gives useful indexes, and I was pondering to give the widestring wrapper object the correct result (= character offsets) from that function, not byteoffsets.
I also need the reverse function for continued search (start_index).
/ Mirar
Previous text:
2003-09-24 12:25: Subject: utf8_char_index
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 ()