Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用从特定字节和字符位置开始utf8.offset(s, n, i)查找字符的偏移量?n该i参数记录为:
utf8.offset(s, n, i)
n
i
返回 s 的第 n 个字符(从位置 i 开始计数)的编码开始的位置(以字节为单位)...
我得到i的是我需要的,但我不明白它是字节位置还是字符位置。我该如何使用它?
Lua 手册中的所有字符串偏移量都以字节为单位,除非手册另有说明。i字节偏移量也是如此,utf8.offset返回值也是如此。
utf8.offset