utf8_tool
简介
一个用于操作utf-8格式字符串的库,
由于gs自带的字符串操作多是以字节为单位,在操作多字节字符时多有不便, 使用utf8_tool可以对utf-8格式的字符串进行以字符为单位进行操作。
组件接口
unicode.gs
支持utf8到Unicode的转换
TODO
Overlong encodings, see https://en.wikipedia.org/wiki/UTF-8
函数原型 | 函数作用 |
---|---|
int peek(string str, int off) | 返回当前位置的codepoint |
int skip(string str, int off) | 返回下一个codepoint的位置 |
array next(string str, int off) | 返回当前位置的codepoint,并移动到下一个codepoint的位置 |
bool is_chinese(int codepoint) | 检查是否为中文字符 |