It would also be possible to generate a byte-offset -> index table when generating the UTF-8 from the widestring. Then it would be O(1), but it would use 4 bytes more memory for each byte.
/ Per Hedbor ()
Previous text:
2003-09-24 12:28: Subject: utf8_char_index
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