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-levelconst is unsupported) so the branches read in characters, not
decimals.
Free functions
| Type | Method and description |
|---|---|
| isAscii(c : i32) : bool true when c is a 7-bit ASCII codepoint (0..=127). |
| isUpper(c : i32) : bool true when c is an uppercase ASCII letter 'A'..='Z'. |
| isLower(c : i32) : bool true when c is a lowercase ASCII letter 'a'..='z'. |
| isAlpha(c : i32) : bool true when c is an ASCII letter (either case). |
| isDigit(c : i32) : bool true when c is an ASCII decimal digit '0'..='9'. |
| isAlphanumeric(c : i32) : bool true when c is an ASCII letter or decimal digit. |
| isHexDigit(c : i32) : bool true when c is a hex digit 0-9, 'a'-'f' or 'A'-'F'. |
| isWhitespace(c : i32) : bool space, \t, \n, \v, \f, \r — the C isspace set. |
| isControl(c : i32) : bool Control : 0..0x1f or 0x7f. |
| isPrintable(c : i32) : bool Printable : 0x20..=0x7e. |
| isPunctuation(c : i32) : bool Punctuation : printable ASCII minus alphanumeric and space, i.e.!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ |
| 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. |
| toLowerAscii(c : i32) : i32 Lowercase a single ASCII letter; non-ASCII passes through unchanged. |
| 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. |
| hexLower(nibble : i32) : i32 Lowercase hex digit (ASCII) for a nibble value 0..15. |
| hexUpper(nibble : i32) : i32 Uppercase hex digit (ASCII) for a nibble value 0..15. |
Method detail
#isAscii
true when c is a 7-bit ASCII codepoint (0..=127).
c codepoint to classify; values ≥ 128 yield false#isUpper
true when c is an uppercase ASCII letter 'A'..='Z'.
c codepoint to test against the 65..=90 ('A'..'Z') range#isLower
true when c is a lowercase ASCII letter 'a'..='z'.
c codepoint to test against the 97..=122 ('a'..'z') range#isAlpha
true when c is an ASCII letter (either case).
c codepoint to test; passes if upper- or lower-case ASCII#isDigit
true when c is an ASCII decimal digit '0'..='9'.
c codepoint to test against the 48..=57 ('0'..'9') range#isAlphanumeric
true when c is an ASCII letter or decimal digit.
c codepoint to test; passes if alphabetic or a digit#isHexDigit
true when c is a hex digit 0-9, 'a'-'f' or 'A'-'F'.
c codepoint to test against the decimal and 'a'..'f'/'A'..'F' ranges#isWhitespace
space, \t, \n, \v, \f, \r — the C isspace set.
c codepoint to test against the six whitespace codes (9..13, 32)#isControl
Control : 0..0x1f or 0x7f.
c codepoint to test against the C0 controls (0..31) and DEL (127)#isPrintable
Printable : 0x20..=0x7e.
c codepoint to test against the printable range (space..'~', 32..126)#isPunctuation
Punctuation : printable ASCII minus alphanumeric and space, i.e.!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
c codepoint to test; passes if printable but not space or alphanumeric#toUpperAscii
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.
c codepoint to fold; only 'a'..'z' is shifted, all else passes through#toLowerAscii
Lowercase a single ASCII letter; non-ASCII passes through unchanged.
c codepoint to fold; only 'A'..'Z' is shifted, all else passes through#hexVal
Nibble value 0..15 for a hex-digit character (upper- or lower-case),
or -1 if c is not a hex digit.
c hex-digit codepoint to decode; non-hex inputs yield -1#hexLower
Lowercase hex digit (ASCII) for a nibble value 0..15.
nibble 4-bit value 0..15 to render as '0'..'9'/'a'..'f'#hexUpper
Uppercase hex digit (ASCII) for a nibble value 0..15.
nibble 4-bit value 0..15 to render as '0'..'9'/'A'..'F'