strconv+x86_64 +linux

The strconv module provides functions for parsing strings into numeric datatypes and formatting numbers into strings.

Index

Types

type base;

Errors

type error;
type invalid;
type overflow;

Functions

fn f32tos(f32) const str;
fn f64tos(f64) const str;
fn floatingtos(types::floating) const str;
fn floatingtosb(types::floating, base) const str;
fn i16tos(i16) const str;
fn i16tosb(i16, base) const str;
fn i32tos(i32) const str;
fn i32tosb(i32, base) const str;
fn i64tos(i64) const str;
fn i64tosb(i64, base) const str;
fn i8tos(i8) const str;
fn i8tosb(i8, base) const str;
fn integertos(types::integer) const str;
fn integertosb(types::integer, base) const str;
fn itos(int) const str;
fn itosb(int, base) const str;
fn numerictos(types::numeric) const str;
fn numerictosb(types::numeric, base) const str;
fn signedtos(types::signed) const str;
fn signedtosb(types::signed, base) const str;
fn stof32(str) (f32 | invalid | overflow);
fn stof64(str) (f64 | invalid | overflow);
fn stoi(str) (int | invalid | overflow);
fn stoi16(str) (i16 | invalid | overflow);
fn stoi16b(str, base) (i16 | invalid | overflow);
fn stoi32(str) (i32 | invalid | overflow);
fn stoi32b(str, base) (i32 | invalid | overflow);
fn stoi64(str) (i64 | invalid | overflow);
fn stoi64b(str, base) (i64 | invalid | overflow);
fn stoi8(str) (i8 | invalid | overflow);
fn stoi8b(str, base) (i8 | invalid | overflow);
fn stoib(str, base) (int | invalid | overflow);
fn stou(str) (uint | invalid | overflow);
fn stou16(str) (u16 | invalid | overflow);
fn stou16b(str, base) (u16 | invalid | overflow);
fn stou32(str) (u32 | invalid | overflow);
fn stou32b(str, base) (u32 | invalid | overflow);
fn stou64(str) (u64 | invalid | overflow);
fn stou64b(str, base) (u64 | invalid | overflow);
fn stou8(str) (u8 | invalid | overflow);
fn stou8b(str, base) (u8 | invalid | overflow);
fn stoub(str, base) (uint | invalid | overflow);
fn stoz(str) (size | invalid | overflow);
fn stozb(str, base) (size | invalid | overflow);
fn strerror(error) str;
fn u16tos(u16) const str;
fn u16tosb(u16, base) const str;
fn u32tos(u32) const str;
fn u32tosb(u32, base) const str;
fn u64tos(u64) const str;
fn u64tosb(u64, base) const str;
fn u8tos(u8) const str;
fn u8tosb(u8, base) const str;
fn unsignedtos(types::unsigned) const str;
fn unsignedtosb(types::unsigned, base) const str;
fn uptrtos(uintptr) const str;
fn uptrtosb(uintptr, base) const str;
fn utos(uint) const str;
fn utosb(uint, base) const str;
fn ztos(size) const str;
fn ztosb(size, base) const str;

Types

type base[link]

type base = enum uint {
	DEFAULT = 0, // Default base - decimal
BIN = 2, // Base 2, binary
OCT = 8, // Base 8, octal
DEC = 10, // Base 10, decimal
HEX_UPPER = 16, // Base 16, UPPERCASE hexadecimal
HEX = 16, // Alias for HEX_UPPER
HEX_LOWER = 17, // Base 16, lowercase hexadecimal
};

The valid numeric bases for numeric conversions.

Errors

type error[link]

type error = !(invalid | overflow);

Any error which may be returned from a strconv function.

type invalid[link]

type invalid = !size;

Indicates that the input string doesn't have the requested number format (integer or float). Contains the index of the first invalid rune.

type overflow[link]

type overflow = !void;

Indicates that the input member can't be represented by the requested data type.

Functions

fn f32tos[link]

fn f32tos(n: f32) const str;

Converts a f32 to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn f64tos[link]

fn f64tos(n: f64) const str;

Converts a f64 to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn floatingtos[link]

fn floatingtos(n: types::floating) const str;

Converts any types::floating to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn floatingtosb[link]

fn floatingtosb(n: types::floating, b: base) const str;

Converts any types::floating to a string in a given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn i16tos[link]

fn i16tos(i: i16) const str;

Converts an i16 to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn i16tosb[link]

fn i16tosb(i: i16, b: base) const str;

Converts an i16 to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn i32tos[link]

fn i32tos(i: i32) const str;

Converts an i32 to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn i32tosb[link]

fn i32tosb(i: i32, b: base) const str;

Converts an i32 to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn i64tos[link]

fn i64tos(i: i64) const str;

Converts an i64 to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn i64tosb[link]

fn i64tosb(i: i64, b: base) const str;

Converts an i64 to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn i8tos[link]

fn i8tos(i: i8) const str;

Converts an i8 to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn i8tosb[link]

fn i8tosb(i: i8, b: base) const str;

Converts an i8 to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn integertos[link]

fn integertos(n: types::integer) const str;

Converts any types::integer to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn integertosb[link]

fn integertosb(n: types::integer, b: base) const str;

Converts any types::integer to a string in a given base, which must be 2, 8, 10, or 16. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn itos[link]

fn itos(i: int) const str;

Converts an int to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn itosb[link]

fn itosb(i: int, b: base) const str;

Converts an int to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn numerictos[link]

fn numerictos(n: types::numeric) const str;

Converts any types::numeric to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn numerictosb[link]

fn numerictosb(n: types::numeric, b: base) const str;

Converts any types::numeric to a string in a given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn signedtos[link]

fn signedtos(n: types::signed) const str;

Converts any types::signed to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn signedtosb[link]

fn signedtosb(n: types::signed, b: base) const str;

Converts any types::signed to a string in a given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn stof32[link]

fn stof32(s: str) (f32 | invalid | overflow);

Converts a string to a f32. If the string is not syntactically well-formed floating-point number in base 10, invalid is returned. If the string represents a floating-point number that is larger than the largest finite f64 number, overflow is returned. Zero is returned if the string represents a floating-point number that is smaller than the f32 number nearest to zero with respective sign. Recognizes "Infinity", "+Infinity", "-Infinity", and "NaN", case insensitive.

fn stof64[link]

fn stof64(s: str) (f64 | invalid | overflow);

Converts a string to a f64. If the string is not syntactically well-formed floating-point number in base 10, invalid is returned. If the string represents a floating-point number that is larger than the largest finite f64 number, overflow is returned. Zero is returned if the string represents a floating-point number that is smaller than the f64 number nearest to zero with respective sign. Recognizes "Infinity", "+Infinity", "-Infinity", and "NaN", case insensitive.

fn stoi[link]

fn stoi(s: str) (int | invalid | overflow);

Converts a string to an int in base 10, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by an int, overflow is returned.

fn stoi16[link]

fn stoi16(s: str) (i16 | invalid | overflow);

Converts a string to an i16 in base 10, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by an i16, overflow is returned.

fn stoi16b[link]

fn stoi16b(s: str, base: base) (i16 | invalid | overflow);

Converts a string to an i16 in the given base. If the string contains any non-numeric characters, except '-' or '+' at the start, or if it's empty, invalid is returned. If the number is too large to be represented by an i16, overflow is returned.

fn stoi32[link]

fn stoi32(s: str) (i32 | invalid | overflow);

Converts a string to an i32 in base 10, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by an i32, overflow is returned.

fn stoi32b[link]

fn stoi32b(s: str, base: base) (i32 | invalid | overflow);

Converts a string to an i32 in the given base. If the string contains any non-numeric characters, except '-' or '+' at the start, or if it's empty, invalid is returned. If the number is too large to be represented by an i32, overflow is returned.

fn stoi64[link]

fn stoi64(s: str) (i64 | invalid | overflow);

Converts a string to an i64 in base 10, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by an i64, overflow is returned.

fn stoi64b[link]

fn stoi64b(s: str, base: base) (i64 | invalid | overflow);

Converts a string to an i64 in the given base. If the string contains any non-numeric characters, except '-' or '+' at the start, or if it's empty, invalid is returned. If the number is too large to be represented by an i64, overflow is returned.

fn stoi8[link]

fn stoi8(s: str) (i8 | invalid | overflow);

Converts a string to an i8 in base 10, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by an i8, overflow is returned.

fn stoi8b[link]

fn stoi8b(s: str, base: base) (i8 | invalid | overflow);

Converts a string to an i8 in the given base. If the string contains any non-numeric characters, except '-' or '+' at the start, or if it's empty, invalid is returned. If the number is too large to be represented by an i8, overflow is returned.

fn stoib[link]

fn stoib(s: str, base: base) (int | invalid | overflow);

Converts a string to an int in the given base. If the string contains any non-numeric characters, except '-' or '+' at the start, or if it's empty, invalid is returned. If the number is too large to be represented by an int, overflow is returned.

fn stou[link]

fn stou(s: str) (uint | invalid | overflow);

Converts a string to a uint in base 10, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a uint, overflow is returned.

fn stou16[link]

fn stou16(s: str) (u16 | invalid | overflow);

Converts a string to a u16 in base 10, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a u16, overflow is returned.

fn stou16b[link]

fn stou16b(s: str, base: base) (u16 | invalid | overflow);

Converts a string to a u16 in the given base, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a u16, overflow is returned.

fn stou32[link]

fn stou32(s: str) (u32 | invalid | overflow);

Converts a string to a u32 in base 10, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a u32, overflow is returned.

fn stou32b[link]

fn stou32b(s: str, base: base) (u32 | invalid | overflow);

Converts a string to a u32 in the given base, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a u32, overflow is returned.

fn stou64[link]

fn stou64(s: str) (u64 | invalid | overflow);

Converts a string to a u64 in base 10, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a u64, overflow is returned.

fn stou64b[link]

fn stou64b(s: str, base: base) (u64 | invalid | overflow);

Converts a string to a u64 in the given base, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a u64, overflow is returned.

fn stou8[link]

fn stou8(s: str) (u8 | invalid | overflow);

Converts a string to a u8 in base 10, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a u8, overflow is returned.

fn stou8b[link]

fn stou8b(s: str, base: base) (u8 | invalid | overflow);

Converts a string to a u8 in the given base, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a u8, overflow is returned.

fn stoub[link]

fn stoub(s: str, base: base) (uint | invalid | overflow);

Converts a string to a uint in the given base, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a uint, overflow is returned.

fn stoz[link]

fn stoz(s: str) (size | invalid | overflow);

Converts a string to a size in base 10, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a size, overflow is returned.

fn stozb[link]

fn stozb(s: str, base: base) (size | invalid | overflow);

Converts a string to a size in the given base, If the string contains any non-numeric characters, or if it's empty, invalid is returned. If the number is too large to be represented by a size, overflow is returned.

fn strerror[link]

fn strerror(err: error) str;

Converts an strconv error into a user-friendly string.

fn u16tos[link]

fn u16tos(u: u16) const str;

Converts a u16 to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn u16tosb[link]

fn u16tosb(u: u16, b: base) const str;

Converts a u16 to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn u32tos[link]

fn u32tos(u: u32) const str;

Converts a u32 to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn u32tosb[link]

fn u32tosb(u: u32, b: base) const str;

Converts a u32 to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn u64tos[link]

fn u64tos(u: u64) const str;

Converts a u64 to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn u64tosb[link]

fn u64tosb(u: u64, b: base) const str;

Converts a u64 to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn u8tos[link]

fn u8tos(u: u8) const str;

Converts a u8 to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn u8tosb[link]

fn u8tosb(u: u8, b: base) const str;

Converts a u8 to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn unsignedtos[link]

fn unsignedtos(n: types::unsigned) const str;

Converts any types::unsigned to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn unsignedtosb[link]

fn unsignedtosb(n: types::unsigned, b: base) const str;

Converts any types::unsigned to a string in a given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn uptrtos[link]

fn uptrtos(uptr: uintptr) const str;

Converts a uintptr to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn uptrtosb[link]

fn uptrtosb(uptr: uintptr, b: base) const str;

Converts a uintptr to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn utos[link]

fn utos(u: uint) const str;

Converts a uint to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn utosb[link]

fn utosb(u: uint, b: base) const str;

Converts a uint to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.

fn ztos[link]

fn ztos(z: size) const str;

Converts a size to a string in base 10. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result, or itosb to pass your own string buffer.

fn ztosb[link]

fn ztosb(u: size, b: base) const str;

Converts a size to a string in the given base. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to duplicate the result.