1+ // https://www.lua.org/manual/5.5/manual.html#6.6
2+
3+ /**
4+ * This library provides basic support for UTF-8 encoding. It provides all its
5+ * functions inside the table utf8. This library does not provide any support
6+ * for Unicode other than the handling of the encoding. Any operation that needs
7+ * the meaning of a character, such as character classification, is outside its
8+ * scope.
9+ *
10+ * Unless stated otherwise, all functions that expect a byte position as a
11+ * parameter assume that the given position is either the start of a byte
12+ * sequence or one plus the length of the subject string. As in the string
13+ * library, negative indices count from the end of the string.
14+ */
15+ declare namespace utf8 {
16+ /**
17+ * Returns the position of the n-th character of s (counting from byte
18+ * position i) as two integers: The index (in bytes) where its encoding
19+ * starts and the index (in bytes) where it ends.
20+ *
21+ * If the specified character is right after the end of s, the function
22+ * behaves as if there was a '\0' there. If the specified character is
23+ * neither in the subject nor right after its end, the function returns fail.
24+ *
25+ * A negative n gets characters before position i. The default for i is 1
26+ * when n is non-negative and #s + 1 otherwise, so that utf8.offset(s,-n)
27+ * gets the offset of the n-th character from the end of the string.
28+ *
29+ * As a special case, when n is 0 the function returns the start of the
30+ * encoding of the character that contains the i-th byte of s.
31+ *
32+ * This function assumes that s is a valid UTF-8 string.
33+ */
34+ function offset ( s : string , n ?: number , i ?: number ) : LuaMultiReturn < [ number , number ] > ;
35+ }
0 commit comments