Skip to main content

string

include "string";

Text: the methods every string has (length, slicing, searching), and conversion between strings, numbers and buffers.

Types​

string​

Built-in type

length infallible​

infallible fn length() -> int

slice​

fn slice(int offset, int count) -> string

find​

fn find(string needle, int start) -> int

ascii_lower infallible​

infallible fn ascii_lower() -> string

byte_at​

fn byte_at(int index) -> int

chars infallible​

infallible fn chars() -> array<char>

range_equals​

fn range_equals(int offset, string other, int other_offset, int count) -> bool

to_buffer​

fn to_buffer() -> buffer

A new buffer holding the string's bytes.

Functions​

int_to_string infallible​

infallible fn int_to_string(int value) -> string

Formats value as decimal digits.

char_to_string infallible​

infallible fn char_to_string(char value) -> string

The character as text: its UTF-8 bytes. The zero character '\0' gives the empty string, since strings hold no NUL byte.

float_to_string infallible​

infallible fn float_to_string(float value, int decimals) -> string

Formats value with the given number of digits after the decimal point.

int_from_string​

fn int_from_string(string text) -> int

Parses a whole string as a decimal integer.

float_from_string​

fn float_from_string(string text) -> float

Parses a whole string as a floating-point number.

Methods on other packages' types​