Module

std::char

Char Module

Character and UTF-8 scalar classification helpers.

char is a native Unicode scalar. Byte-backed text traversal keeps offsets internal to string and cursor helpers, while the classification helpers in this module accept native char values directly. This keeps scalar semantics ergonomic while keeping ASCII-only behavior explicit:

  • isAscii* helpers classify char values without byte casts.
  • isAlpha, isNumeric, isAlphanumeric, and isWhitespace classify Unicode scalar char values.

Examples

import Char from "std::char";

let letter: char = 'é';
let digit: char = '5';

letter.isAlpha();        // true
digit.isNumeric();       // true
Char::isAsciiAlpha('A'); // true
namespace Char

Character and UTF-8 scalar classification helpers.

Methods whose names include Ascii intentionally classify only ASCII characters. Methods without that prefix operate on native Unicode scalar char values.

Functions

function asciiDigitValue(value: char): Option<u64>

Returns the numeric value of an ASCII decimal digit.

Non-ASCII digits, including Unicode decimal digits, return Option::NONE.

function isAlpha(value: char): boolean

Returns whether value is an alphabetic Unicode scalar.

This covers the scalar ranges needed by current parser/diagnostic text handling without pretending that char literals are raw bytes.

Example

import Char from "std::char";

let latin: char = 'é';
let cjk: char = '中';
let digit: char = '5';

latin.isAlpha(); // true
cjk.isAlpha();   // true
digit.isAlpha(); // false
function isAlphabetic(value: char): boolean

Returns whether value is an alphabetic Unicode scalar.

This is an alias for isAlpha using the longer Rust-style name.

Example

import Char from "std::char";

let lambda: char = 'λ';

lambda.isAlphabetic(); // true
function isAlphanumeric(value: char): boolean

Returns whether value is an alphabetic or numeric Unicode scalar.

Example

import Char from "std::char";

let letter: char = 'A';
let digit: char = '5';
let underscore: char = '_';

letter.isAlphanumeric();     // true
digit.isAlphanumeric();      // true
underscore.isAlphanumeric(); // false
function isAsciiAlpha(value: char): boolean

Returns whether value is an ASCII alphabetic character.

Example

import Char from "std::char";

let ascii: char = 'A';
let unicode: char = 'é';

ascii.isAsciiAlpha();    // true
unicode.isAsciiAlpha();  // false
function isAsciiAlphanumeric(value: char): boolean

Returns whether value is ASCII alphabetic or numeric.

Example

import Char from "std::char";

let letter: char = 'x';
let underscore: char = '_';

letter.isAsciiAlphanumeric();     // true
underscore.isAsciiAlphanumeric(); // false
function isAsciiHexDigit(value: char): boolean

Returns whether value is an ASCII hexadecimal digit.

Example

import Char from "std::char";

let hex: char = 'f';
let other: char = 'g';

hex.isAsciiHexDigit();   // true
other.isAsciiHexDigit(); // false
function isAsciiLowercase(value: char): boolean

Returns whether value is an ASCII lowercase letter.

Example

import Char from "std::char";

let lower: char = 'a';
let upper: char = 'A';

lower.isAsciiLowercase(); // true
upper.isAsciiLowercase(); // false
function isAsciiNumeric(value: char): boolean

Returns whether value is an ASCII decimal digit.

Example

import Char from "std::char";

let ascii: char = '7';
let fullWidth: char = '5';

ascii.isAsciiNumeric();     // true
fullWidth.isAsciiNumeric(); // false
function isAsciiUppercase(value: char): boolean

Returns whether value is an ASCII uppercase letter.

Example

import Char from "std::char";

let upper: char = 'A';
let lower: char = 'a';

upper.isAsciiUppercase(); // true
lower.isAsciiUppercase(); // false
function isAsciiWhitespace(value: char): boolean

Returns whether value is ASCII whitespace supported by Ignis escapes.

This includes space, line feed, carriage return, and tab.

Example

import Char from "std::char";

let newline: char = '\n';
let letter: char = 'A';

newline.isAsciiWhitespace(); // true
letter.isAsciiWhitespace();  // false
function isDigit(value: char): boolean

Returns whether value is a numeric Unicode scalar.

This is an alias for isNumeric.

Example

import Char from "std::char";

let digit: char = '9';

digit.isDigit(); // true
function isHexDigit(value: char): boolean

Returns whether value is a hexadecimal ASCII scalar.

This intentionally follows ASCII hexadecimal syntax. Use isNumeric for broader Unicode digit classification.

Example

import Char from "std::char";

let hex: char = 'F';
let fullWidth: char = 'G';

hex.isHexDigit();       // true
fullWidth.isHexDigit(); // false
function isNumeric(value: char): boolean

Returns whether value is a numeric Unicode scalar.

This includes ASCII digits, Arabic-Indic digits, and full-width digits.

Example

import Char from "std::char";

let ascii: char = '7';
let fullWidth: char = '5';

ascii.isNumeric();     // true
fullWidth.isNumeric(); // true
function isWhitespace(value: char): boolean

Returns whether value is a Unicode whitespace scalar.

Example

import Char from "std::char";

let space: char = ' ';
let nonBreakingSpace: char = 160 as char;

space.isWhitespace();            // true
nonBreakingSpace.isWhitespace(); // true
function scalarOf(value: char): u32

Returns the Unicode scalar value stored by value.

Use this only when numeric scalar ranges are required. Text-facing code should prefer the semantic classification helpers below.

Example

import Char from "std::char";

let code: u32 = Char::scalarOf('é');  // 233
function toAsciiLowercase(value: char): char

Converts an ASCII uppercase letter to lowercase.

Non-uppercase characters are returned unchanged.

Example

import Char from "std::char";

let upper: char = 'A';
let unicode: char = 'é';

upper.toAsciiLowercase();   // 'a'
unicode.toAsciiLowercase(); // 'é'
function toAsciiUppercase(value: char): char

Converts an ASCII lowercase letter to uppercase.

Non-lowercase characters are returned unchanged.

Example

import Char from "std::char";

let lower: char = 'a';
let unicode: char = 'é';

lower.toAsciiUppercase();   // 'A'
unicode.toAsciiUppercase(); // 'é'

Functions

function isCjkAlpha(scalar: u32): boolean
function isCyrillicAlpha(scalar: u32): boolean
function isGreekAlpha(scalar: u32): boolean
function isLatinAlpha(scalar: u32): boolean