utf8.offset: how to specify starting positions?

742 Views Asked by At

How can I use utf8.offset(s, n, i) to find the offset of the character at n starting from specific byte and character positions? The i parameter is documented as:

Returns the position (in bytes) where the encoding of the n-th character of s (counting from position i) starts...

I got i is what I need, but I can't understand if it's byte position or character position. How can I use it?

1

There are 1 best solutions below

2
On BEST ANSWER

All string offsets in the Lua manual are in bytes, unless the manual specifically says otherwise. So i is a byte offset, as is utf8.offset's return value.