pub fn offset(
s: string,
n: number,
i: option<number>,
) -> option<(number, number)>Expand description
Returns the position (in bytes) where the encoding of the n-th
character of s (counting from byte position i) starts, and —
since Lua 5.5 — also the position of the final byte of that
character. A negative n gets characters before position i.
utf8.offset(s, -1) gets the last character of the string.
§Examples
print(utf8.offset("héllo", 2)) --> 2 3 (é spans bytes 2-3)
print(utf8.offset("héllo", 3)) --> 4 4 (l is a single byte)
print(utf8.offset("héllo", -1)) --> 6 6 (the last char)