ascii
The ascii module provides helper functions for working with the subset of Unicode which is defined by the American Standard Code for Information Interchange (ASCII).
Index
Functions
fn isalnum(c: rune) bool;
fn isalpha(c: rune) bool;
fn isblank(c: rune) bool;
fn iscntrl(c: rune) bool;
fn isdigit(c: rune) bool;
fn isgraph(c: rune) bool;
fn islower(c: rune) bool;
fn isprint(c: rune) bool;
fn ispunct(c: rune) bool;
fn isspace(c: rune) bool;
fn isupper(c: rune) bool;
fn isxdigit(c: rune) bool;
fn strcasecmp(a: str, b: str) int;
fn strlower(s: str) str;
fn strlower_buf(s: str, buf: []u8) str;
fn strupper(s: str) str;
fn strupper_buf(s: str, buf: []u8) str;
fn tolower(c: rune) rune;
fn toupper(c: rune) rune;
fn valid(c: rune) bool;
fn validstr(s: str) bool;
Functions
fn isalnum
fn isalnum(c: rune) bool;
Returns true if an ASCII character is alphanumeric.
fn isalpha
fn isalpha(c: rune) bool;
Returns true if an ASCII character is a letter.
fn isblank
fn isblank(c: rune) bool;
Returns true if a rune is a space or a tab.
fn iscntrl
fn iscntrl(c: rune) bool;
Returns true if an ASCII character is a control character.
fn isdigit
fn isdigit(c: rune) bool;
Returns true if an ASCII character is a digit.
fn isgraph
fn isgraph(c: rune) bool;
Returns true if an ASCII character is any printable character other than space.
fn islower
fn islower(c: rune) bool;
Returns true if an ASCII character is lowercase.
fn isprint
fn isprint(c: rune) bool;
Returns true if an ASCII character is printable.
fn ispunct
fn ispunct(c: rune) bool;
Returns true if an ASCII character is punctuation.
fn isspace
fn isspace(c: rune) bool;
Returns true if an ASCII character is a white-space character - one of '\f', '\n', '\r', '\t', '\v', ' '.
fn isupper
fn isupper(c: rune) bool;
Returns true if an ASCII character is uppercase.
fn isxdigit
fn isxdigit(c: rune) bool;
Returns true if an ASCII character is a hexadecimal digit.
fn strcasecmp
fn strcasecmp(a: str, b: str) int;
Compares two strings by their sort order, treating all ASCII capital letters as their lowercase counterpart (i.e. an ASCII-case-insensitive comparison is performed). Zero is returned if the strings are equal, a negative value if a is less than b, or a positive value if a is greater than b.
fn strlower
fn strlower(s: str) str;
Converts all ASCII uppercase characters in a string to their lowercase representation, returning a new string. The return value must be freed by the caller.
fn strlower_buf
fn strlower_buf(s: str, buf: []u8) str;
Converts all ASCII uppercase characters in a string to their lowercase representation, returning a new string. The new string data is stored in the supplied buffer (overwriting any existing contents). The buffer is permitted to exactly overlap the string. This function will abort if the buffer's capacity is too small to fit the entire string.
fn strupper
fn strupper(s: str) str;
Converts all ASCII lowercase characters in a string to their uppercase representation, returning a new string. The return value must be freed by the caller.
fn strupper_buf
fn strupper_buf(s: str, buf: []u8) str;
Converts all ASCII lowercase characters in a string to their uppercase representation, returning a new string. The new string data is stored in the supplied buffer (overwriting any existing contents). The buffer is permitted to exactly overlap the string. This function will abort if the buffer's capacity is too small to fit the entire string.
fn tolower
fn tolower(c: rune) rune;
Returns the lowercase form of an ASCII character, or the original character if it was not an uppercase letter (or was not ASCII).
fn toupper
fn toupper(c: rune) rune;
Returns the uppercase form of an ASCII character, or the original character if it was not a lowercase letter (or was not ASCII).
fn valid
fn valid(c: rune) bool;
Returns true if a rune is a valid ASCII character.
fn validstr
fn validstr(s: str) bool;
Returns true if all runes in a string are valid ASCII characters.