Char
Char represents one Unicode scalar, not a byte or UTF-16 code unit. Char
operations do not normalize text or apply locale-sensitive rules.
Conversion
toUInt32
Returns the scalar's numeric Unicode value. This is logically O(1).
fromUInt32
Returns Just for a valid Unicode scalar. Values above 0x10FFFF and values in
the surrogate range return Nothing. This is logically O(1).
Classification
isAlpha
Returns True for Unicode characters in the UppercaseLetter,
LowercaseLetter, TitlecaseLetter, ModifierLetter, or OtherLetter
general category.
isAlphaNum
Returns True for any category accepted by isAlpha, plus
DecimalNumber, LetterNumber, and OtherNumber.
isDigit
Uses the Unicode digit property, not only ASCII 0–9.
isSpace
Uses the Unicode whitespace property.
isHexDigit
Recognizes only ASCII 0–9, a–f, and A–F.
isLower
Returns True only for the Unicode LowercaseLetter general category.
isUpper
Returns True only for the Unicode UppercaseLetter general category.
isNewline
Returns True for line feed ('\n') or carriage return ('\r') and False
for other scalars.
Classification functions are logically O(1).
Case mapping
toLower
Performs simple, locale-independent lowercase mapping. It returns one scalar and never expands a character into multiple values.
toUpper
Performs simple, locale-independent uppercase mapping. It returns one scalar and never expands a character into multiple values.
Literal spelling and escapes are defined by the lexical grammar. Use Text for immutable scalar sequences.