Axle v0.14.1
Package

std/core/ascii

std/ascii — ASCII character classification.

Single-codepoint predicates that mirror C's <ctype.h>. Inputs
outside the ASCII range (≥ 128) always return false — this is
the conservative choice (isAlpha('é') is false).

All operations take a single character represented as i32
(codepoint). Implemented in pure Axle, no FFI.

The ASCII range bounds are named in each function (module-level
const is unsupported) so the branches read in characters, not
decimals.

Free functions

TypeMethod and description
bool
isAscii(c : i32) : bool true when c is a 7-bit ASCII codepoint (0..=127).
bool
isUpper(c : i32) : bool true when c is an uppercase ASCII letter 'A'..='Z'.
bool
isLower(c : i32) : bool true when c is a lowercase ASCII letter 'a'..='z'.
bool
isAlpha(c : i32) : bool true when c is an ASCII letter (either case).
bool
isDigit(c : i32) : bool true when c is an ASCII decimal digit '0'..='9'.
bool
isAlphanumeric(c : i32) : bool true when c is an ASCII letter or decimal digit.
bool
isHexDigit(c : i32) : bool true when c is a hex digit 0-9, 'a'-'f' or 'A'-'F'.
bool
isWhitespace(c : i32) : bool space, \t, \n, \v, \f, \r — the C isspace set.
bool
isControl(c : i32) : bool Control : 0..0x1f or 0x7f.
bool
isPrintable(c : i32) : bool Printable : 0x20..=0x7e.
bool
isPunctuation(c : i32) : bool Punctuation : printable ASCII minus alphanumeric and space, i.e.

!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
i32
toUpperAscii(c : i32) : i32 Case folding (single ASCII codepoint). Non-ASCII passes through
unchanged.

The 'a'..'z' and 'A'..'Z' rows are 0x20 apart, so the case bit is
bit 5 (0x20): clearing it folds to upper, setting it folds to lower.
i32
toLowerAscii(c : i32) : i32 Lowercase a single ASCII letter; non-ASCII passes through unchanged.
i32
hexVal(c : i32) : i32 Nibble value 0..15 for a hex-digit character (upper- or lower-case),
or -1 if c is not a hex digit.
i32
hexLower(nibble : i32) : i32 Lowercase hex digit (ASCII) for a nibble value 0..15.
i32
hexUpper(nibble : i32) : i32 Uppercase hex digit (ASCII) for a nibble value 0..15.

Method detail

#isAscii

isAscii(c : i32) : bool

true when c is a 7-bit ASCII codepoint (0..=127).

Parameters
c codepoint to classify; values ≥ 128 yield false

#isUpper

isUpper(c : i32) : bool

true when c is an uppercase ASCII letter 'A'..='Z'.

Parameters
c codepoint to test against the 65..=90 ('A'..'Z') range

#isLower

isLower(c : i32) : bool

true when c is a lowercase ASCII letter 'a'..='z'.

Parameters
c codepoint to test against the 97..=122 ('a'..'z') range

#isAlpha

isAlpha(c : i32) : bool

true when c is an ASCII letter (either case).

Parameters
c codepoint to test; passes if upper- or lower-case ASCII

#isDigit

isDigit(c : i32) : bool

true when c is an ASCII decimal digit '0'..='9'.

Parameters
c codepoint to test against the 48..=57 ('0'..'9') range

#isAlphanumeric

isAlphanumeric(c : i32) : bool

true when c is an ASCII letter or decimal digit.

Parameters
c codepoint to test; passes if alphabetic or a digit

#isHexDigit

isHexDigit(c : i32) : bool

true when c is a hex digit 0-9, 'a'-'f' or 'A'-'F'.

Parameters
c codepoint to test against the decimal and 'a'..'f'/'A'..'F' ranges

#isWhitespace

isWhitespace(c : i32) : bool

space, \t, \n, \v, \f, \r — the C isspace set.

Parameters
c codepoint to test against the six whitespace codes (9..13, 32)

#isControl

isControl(c : i32) : bool

Control : 0..0x1f or 0x7f.

Parameters
c codepoint to test against the C0 controls (0..31) and DEL (127)

#isPrintable

isPrintable(c : i32) : bool

Printable : 0x20..=0x7e.

Parameters
c codepoint to test against the printable range (space..'~', 32..126)

#isPunctuation

isPunctuation(c : i32) : bool

Punctuation : printable ASCII minus alphanumeric and space, i.e.

!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

Parameters
c codepoint to test; passes if printable but not space or alphanumeric

#toUpperAscii

toUpperAscii(c : i32) : i32

Case folding (single ASCII codepoint). Non-ASCII passes through
unchanged.

The 'a'..'z' and 'A'..'Z' rows are 0x20 apart, so the case bit is
bit 5 (0x20): clearing it folds to upper, setting it folds to lower.

Parameters
c codepoint to fold; only 'a'..'z' is shifted, all else passes through

#toLowerAscii

toLowerAscii(c : i32) : i32

Lowercase a single ASCII letter; non-ASCII passes through unchanged.

Parameters
c codepoint to fold; only 'A'..'Z' is shifted, all else passes through

#hexVal

hexVal(c : i32) : i32

Nibble value 0..15 for a hex-digit character (upper- or lower-case),
or -1 if c is not a hex digit.

Parameters
c hex-digit codepoint to decode; non-hex inputs yield -1

#hexLower

hexLower(nibble : i32) : i32

Lowercase hex digit (ASCII) for a nibble value 0..15.

Parameters
nibble 4-bit value 0..15 to render as '0'..'9'/'a'..'f'

#hexUpper

hexUpper(nibble : i32) : i32

Uppercase hex digit (ASCII) for a nibble value 0..15.

Parameters
nibble 4-bit value 0..15 to render as '0'..'9'/'A'..'F'