XU XUv0.8.8
中文

API

#strconv

import: #strconv

counts: 27 fns, 0 methods, 0 types, 0 consts, 0 ifaces

Numbers and quoting: atoi/itoa, parse/format, quote/unquote, and append_*.

atoi

XuAPI
pub fn atoi(s &string) int

Purpose

Parse a decimal string as int.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

int — a value of this type

itoa

XuAPI
pub fn itoa(n int) string

Purpose

Format an int as a decimal string.

Parameters

n int
count, length, or limit (int)

Returns

string — result string

format_bool

XuAPI
pub fn format_bool(b bool) string

Purpose

Format as bool.

Parameters

b bool
b (bool)

Returns

string — result string

parse_bool

XuAPI
pub fn parse_bool(s &string) bool

Purpose

Parse as bool. Throws on failure.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

bool — true or false

format_int

XuAPI
pub fn format_int(n int, base int) string

Purpose

Format as int. Throws on failure.

Parameters

n int
count, length, or limit (int)
base int
numeric base (int)

Returns

string — result string

parse

XuAPI
pub fn parse(s &string, base int) int

Purpose

Parse the input. Throws on failure.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)
base int
numeric base (int)

Returns

int — a value of this type

format_uint

XuAPI
pub fn format_uint(n int, base int) string

Purpose

===================== f64 parsing / formatting (m34) ===================== parse_float / format_float aligned with strconv.ParseFloat(s, 64) and strconv.FormatFloat(f, byte, prec, 64). All decimal<->binary conversion is done with an exact little-endian base-2^30 bignum (no float bits, no recursion); f64 is only touched at the boundary (f64(int) / int(f64) casts and ieee arithmetic), so results are correctly rounded and byte-identical with for the fixture vectors. Throws on failure.

Parameters

n int
count, length, or limit (int)
base int
numeric base (int)

Returns

string — result string

parse_uint

XuAPI
pub fn parse_uint(s &string, base int) int

Purpose

Parse as uint. Throws on failure.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)
base int
numeric base (int)

Returns

int — a value of this type

quote

XuAPI
pub fn quote(s &string) string

Purpose

Quote and escape.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

string — result string

unquote

XuAPI
pub fn unquote(s &string) string

Purpose

Unquote and unescape. Throws on failure.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

string — result string

quote_rune

XuAPI
pub fn quote_rune(r int) string

Purpose

QuoteRune: single-quoted character literal. Printable Unicode is kept as UTF-8; C0/c1 and other non-ASCII-controls use \x / \u / \U. Not a full unicode.IsPrint table — runes >= 0xA0 are emitted as themselves.

Parameters

r int
rune (Unicode code point) (int)

Returns

string — result string

is_print

XuAPI
pub fn is_print(r int) bool

Purpose

Whether it is print.

Parameters

r int
rune (Unicode code point) (int)

Returns

bool — true or false

is_graphic

XuAPI
pub fn is_graphic(r int) bool

Purpose

Whether it is graphic.

Parameters

r int
rune (Unicode code point) (int)

Returns

bool — true or false

quote_rune_to_ascii

XuAPI
pub fn quote_rune_to_ascii(r int) string

Purpose

Quote rune to ascii.

Parameters

r int
rune (Unicode code point) (int)

Returns

string — result string

quote_to_ascii

XuAPI
pub fn quote_to_ascii(s &string) string

Purpose

Quote to ascii.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

string — result string

append_quote_to_ascii

XuAPI
pub fn append_quote_to_ascii(dst string, s &string) string

Purpose

Append quote to ascii.

Parameters

dst string
destination (string)
s &string
source string (borrowed; caller keeps it; type &string)

Returns

string — result string

append_quote_rune_to_ascii

XuAPI
pub fn append_quote_rune_to_ascii(dst string, r int) string

Purpose

Append quote rune to ascii.

Parameters

dst string
destination (string)
r int
rune (Unicode code point) (int)

Returns

string — result string

quoted_prefix

XuAPI
pub fn quoted_prefix(s &string) string

Purpose

Quoted prefix. Throws on failure.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

string — result string

can_backquote

XuAPI
pub fn can_backquote(s &string) bool

Purpose

Can backquote.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

bool — true or false

append_int

XuAPI
pub fn append_int(dst string, n int, base int) string

Purpose

Append int. Throws on failure.

Parameters

dst string
destination (string)
n int
count, length, or limit (int)
base int
numeric base (int)

Returns

string — result string

append_uint

XuAPI
pub fn append_uint(dst string, n int, base int) string

Purpose

Append uint. Throws on failure.

Parameters

dst string
destination (string)
n int
count, length, or limit (int)
base int
numeric base (int)

Returns

string — result string

append_bool

XuAPI
pub fn append_bool(dst string, b bool) string

Purpose

Append bool.

Parameters

dst string
destination (string)
b bool
b (bool)

Returns

string — result string

append_quote

XuAPI
pub fn append_quote(dst string, s &string) string

Purpose

Append quote.

Parameters

dst string
destination (string)
s &string
source string (borrowed; caller keeps it; type &string)

Returns

string — result string

append_quote_rune

XuAPI
pub fn append_quote_rune(dst string, r int) string

Purpose

Append quote rune.

Parameters

dst string
destination (string)
r int
rune (Unicode code point) (int)

Returns

string — result string

append_float

XuAPI
pub fn append_float(dst string, f f64, verb int, prec int) string

Purpose

Append float. Throws on failure.

Parameters

dst string
destination (string)
f f64
floating-point value
verb int
verb (int)
prec int
precision (int)

Returns

string — result string

format_float

XuAPI
pub fn format_float(f f64, verb int, prec int) string

Purpose

FormatFloat(f, byte, prec, 64): verbs 'f'(102), 'e'(101), 'g'(103). Throws on failure.

Parameters

f f64
floating-point value
verb int
verb (int)
prec int
precision (int)

Returns

string — result string

parse_float

XuAPI
pub fn parse_float(s &string) f64

Purpose

ParseFloat(s, 64): sign / int / fraction / exponent, plus NaN and (optionally signed) Inf / Infinity, matched case-insensitively. Throws on failure.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

f64 — a value of this type