# utf8 The `utf8` module provides basic support for UTF-8 encoding. It is compatible with Lua 5.3+ utf8 library. ## utf8.len - Returns the number of UTF-8 characters in the string #### Function Prototype ::: tip API ```lua utf8.len(s: , i: , j: , lax: ) ``` ::: ## utf8.char - Receives zero or more integers, converts each one to its corresponding UTF-8 byte sequence #### Function Prototype ::: tip API ```lua utf8.char(...) ``` ::: ## utf8.codepoint - Returns the codepoints (as integers) from all characters in the string #### Function Prototype ::: tip API ```lua utf8.codepoint(s: , i: , j: ) ``` ::: ## utf8.codes - Returns an iterator (a function) that iterates over all characters in the string #### Function Prototype ::: tip API ```lua utf8.codes(s: , lax: ) ``` ::: ## utf8.offset - Returns the position (in bytes) where the encoding of the n-th character of the string starts #### Function Prototype ::: tip API ```lua utf8.offset(s: , n: , i: ) ``` ::: ## utf8.sub - Returns the substring of s that starts at character i and continues until character j #### Function Prototype ::: tip API ```lua utf8.sub(s: , i: , j: ) ``` ::: ## utf8.reverse - Returns a string with the characters of s in reverse order #### Function Prototype ::: tip API ```lua utf8.reverse(s: ) ``` ::: ## utf8.lastof - Returns the position (in characters) of the last occurrence of pattern in the string s #### Function Prototype ::: tip API ```lua utf8.lastof(s: , pattern: , plain: ) ``` ::: ## utf8.find - Returns the start and end position (in characters) of the first occurrence of pattern in the string s #### Function Prototype ::: tip API ```lua utf8.find(s: , pattern: , init: , plain: ) ``` ::: ## utf8.width - Returns the display width of the string s (usually for terminal alignment) #### Function Prototype ::: tip API ```lua utf8.width(s: ) ``` ::: ## utf8.byte - Returns the internal numerical codes of the characters s[i], s[i+1], ..., s[j] #### Function Prototype ::: tip API ```lua utf8.byte(s: , i: , j: ) ``` :::