I have a byte offset for a byte array containing a UTF-8 encoded string, how can I transform that into a char offset for the corresponding Java String?
NB. this question used to read:
I have a byte offset into a standard Java String, and I would like to convert that to a character offset.
In practice this will mean a method like charOffsetBefore(int byteOffset)
since any byte offset could be in the middle of a code point.
Thanks.