XU XUv0.16.0

#unicode/utf8

导入方式: #unicode/utf8

公开 API: 11 函数, 0 方法, 0 类型, 1 常量, 0 方法集

UTF-8 编解码与合法性。

const RUNE_ERROR

XuAPI
pub const RUNE_ERROR = 65533

用途

常量 RUNE_ERROR,定义了相关的协议或算法配置参数。

rune_start

XuAPI
pub fn rune_start(b int) bool

用途

执行 rune start 操作。

参数

b int
b(int)

返回值

bool — 是否成立

rune_len

XuAPI
pub fn rune_len(r int) int

用途

执行 rune len 操作。失败时抛出错误,调用方需处理或继续传播。

参数

r int
rune(Unicode 码点)(int)

返回值

int — 该类型的值

decode

XuAPI
pub fn decode(s &string, i int) int

用途

从编码数据中还原原始数据。失败时抛出错误,调用方需处理或继续传播。

参数

s &string
源字符串(只读借用,调用方仍持有原值;类型 &string)
i int
下标或整数(int)

返回值

int — 该类型的值

decode_width

XuAPI
pub fn decode_width(s &string, i int) int

用途

解码 width 数据。

参数

s &string
源字符串(只读借用,调用方仍持有原值;类型 &string)
i int
下标或整数(int)

返回值

int — 该类型的值

valid

XuAPI
pub fn valid(s &string) bool

用途

是否合法。

参数

s &string
源字符串(只读借用,调用方仍持有原值;类型 &string)

返回值

bool — 是否成立

rune_count

XuAPI
pub fn rune_count(s &string) int

用途

执行 rune count 操作。

参数

s &string
源字符串(只读借用,调用方仍持有原值;类型 &string)

返回值

int — 该类型的值

encode

XuAPI
pub fn encode(r int) string

用途

执行数据编码并返回结果。

参数

r int
rune(Unicode 码点)(int)

返回值

string — 结果字符串

valid_rune

XuAPI
pub fn valid_rune(r int) bool

用途

执行 valid rune 操作。

参数

r int
rune(Unicode 码点)(int)

返回值

bool — 是否成立

full_rune

XuAPI
pub fn full_rune(s &string) bool

用途

执行 full rune 操作。

参数

s &string
源字符串(只读借用,调用方仍持有原值;类型 &string)

返回值

bool — 是否成立

decode_last

XuAPI
pub fn decode_last(s &string) int

用途

解码 last 数据。失败时抛出错误,调用方需处理或继续传播。

参数

s &string
源字符串(只读借用,调用方仍持有原值;类型 &string)

返回值

int — 该类型的值

append_rune

XuAPI
pub fn append_rune(s &string, r int) string

用途

执行 append rune 操作。

参数

s &string
源字符串(只读借用,调用方仍持有原值;类型 &string)
r int
rune(Unicode 码点)(int)

返回值

string — 结果字符串