March Docs

Char

Char module: character classification and conversion utilities.

Wraps the built-in char_* primitives for idiomatic use. All predicates return Bool; conversions preserve the char type.

Functions

fndigit_valuedigit_value(c : String) : Int#

Returns the numeric value of a digit character (0-9). Panics if not a digit — use digit_value_opt for the fallible variant when the input may not be a digit.

fndigit_value_optdigit_value_opt(c : String) : Option(Int)#

Returns the numeric value of a digit character (0-9) as Some(n), or None if c is not an ASCII digit. Prefer this safe variant when the input comes from user data (file, network, form) — it's the "lookup-miss → Option" arm of the stdlib error-signaling policy.

fnfrom_intfrom_int(n : Int) : String#

Returns the one-byte string for byte value n, taken modulo 256 (so 256 yields byte 0, and -1 yields byte 255). A byte, not a code point: build a multi-byte UTF-8 character one byte at a time.

fnhex_digit_valuehex_digit_value(c : String) : Int#

Returns the hex value of a hex digit (0-9, a-f, A-F). Panics if not a hex digit — use hex_digit_value_opt when the input might not be hex.

fnhex_digit_value_opthex_digit_value_opt(c : String) : Option(Int)#

Returns the hex value of a hex digit (0-9, a-f, A-F) as Some(n), or None if c is not a hex digit. Safe variant for parsing untrusted hex strings.

fnis_alphais_alpha(c : String) : Bool#

Returns true if c is an ASCII letter (a-z or A-Z).

fnis_alphanumericis_alphanumeric(c : String) : Bool#

Returns true if c is an ASCII letter or digit.

fnis_asciiis_ascii(c : String) : Bool#

Returns true if c is ASCII (code point 0-127).

fnis_digitis_digit(c : String) : Bool#

Returns true if c is an ASCII digit (0-9).

fnis_hex_digitis_hex_digit(c : String) : Bool#

Returns true if c is a hex digit (0-9, a-f, A-F).

fnis_loweris_lower(c : String) : Bool#

Returns true if c is an ASCII lowercase letter (a-z).

fnis_printableis_printable(c : String) : Bool#

Returns true if c is a printable ASCII character (code point 32-126).

fnis_upperis_upper(c : String) : Bool#

Returns true if c is an ASCII uppercase letter (A-Z).

fnis_whitespaceis_whitespace(c : String) : Bool#

Returns true if c is an ASCII whitespace character (space, tab, newline, etc.).

fnto_intto_int(c : String) : Int#

Returns the value (0-255) of the first byte of c. A byte, not a code point: for multi-byte UTF-8 text this is the leading byte only.

fnto_lowerto_lower(c : String) : String#

Converts c to lowercase. Non-alphabetic chars are returned unchanged.

fnto_stringto_string(c : String) : String#

Returns a single-character string containing c.

fnto_upperto_upper(c : String) : String#

Converts c to uppercase. Non-alphabetic chars are returned unchanged.