XU XUv0.16.0

#unicode/utf8

import: #unicode/utf8

counts: 11 functions, 0 methods, 0 types, 1 constants, 0 method sets

UTF-8 encode/decode and validation.

const RUNE_ERROR

XuAPI
pub const RUNE_ERROR = 65533

Purpose

Unicode replacement character used by consumers recovering from invalid encoding.

rune_start

XuAPI
pub fn rune_start(b int) bool

Purpose

Rune start.

Parameters

b int
b (int)

Returns

bool — true or false

rune_len

XuAPI
pub fn rune_len(r int) int

Purpose

Rune len. Throws on failure; handle the error or propagate it to the caller.

Parameters

r int
rune (Unicode code point) (int)

Returns

int — a value of this type

decode

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

Purpose

Decode data from encoded representation. Throws on failure; handle the error or propagate it to the caller.

Parameters

s &string
source string (read-only borrow; caller keeps the original; type &string)
i int
index or integer (int)

Returns

int — a value of this type

decode_width

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

Purpose

Decode width data.

Parameters

s &string
source string (read-only borrow; caller keeps the original; type &string)
i int
index or integer (int)

Returns

int — a value of this type

valid

XuAPI
pub fn valid(s &string) bool

Purpose

Whether the value is valid.

Parameters

s &string
source string (read-only borrow; caller keeps the original; type &string)

Returns

bool — true or false

rune_count

XuAPI
pub fn rune_count(s &string) int

Purpose

Rune count.

Parameters

s &string
source string (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

encode

XuAPI
pub fn encode(r int) string

Purpose

Encode data into output format.

Parameters

r int
rune (Unicode code point) (int)

Returns

string — result string

valid_rune

XuAPI
pub fn valid_rune(r int) bool

Purpose

Valid rune.

Parameters

r int
rune (Unicode code point) (int)

Returns

bool — true or false

full_rune

XuAPI
pub fn full_rune(s &string) bool

Purpose

Full rune.

Parameters

s &string
source string (read-only borrow; caller keeps the original; type &string)

Returns

bool — true or false

decode_last

XuAPI
pub fn decode_last(s &string) int

Purpose

Decode last data. Throws on failure; handle the error or propagate it to the caller.

Parameters

s &string
source string (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

append_rune

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

Purpose

Append rune.

Parameters

s &string
source string (read-only borrow; caller keeps the original; type &string)
r int
rune (Unicode code point) (int)

Returns

string — result string