utf8PointerToOffset

fnglong utf8PointerToOffset(string str, string pos)

Converts from a pointer to position within a string to an integer character offset.

Since 2.10, this function allows pos to be before str, and returns a negative offset in this case.

Parameters

stra UTF-8 encoded string
posa pointer to a position within str

Returns

the resulting character offset