模块 utf8
require "utf8"
公开 API
| API | 实现 | 说明 |
|---|---|---|
utf8.offset | byteoffset | 返回 s 中第 n 个字符的字节偏移(n 为负从末尾数) |
utf8.codepoint | codepoint | 返回 s 从 i 到 j 的字符码点序列 |
utf8.char | utfchar | 由若干码点构造 UTF-8 字符串 |
utf8.len | utflen | 返回 s 的字符数;无效序列返回 nil+位置(带 lax 时宽松) |
utf8.codes | iter_codes | 返回遍历 s 字符的迭代器,yield (字节偏移, 码点) |
utf8.charpattern | NULL | 匹配单个 UTF-8 字符的模式串 |