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
charToUInt32
Returns the scalar's numeric Unicode value. This is logically O(1).
charFromUInt32
Returns Just for a valid Unicode scalar. Values above 0x10FFFF and values in
the surrogate range return Nothing. This is logically O(1).
Classification
charIsAlpha
Returns True for Unicode characters in the UppercaseLetter,
LowercaseLetter, TitlecaseLetter, ModifierLetter, or OtherLetter
general category.
charIsAlphaNum
Returns True for any category accepted by charIsAlpha, plus
DecimalNumber, LetterNumber, and OtherNumber.
charIsDigit
Uses the Unicode digit property, not only ASCII 0–9.
charIsSpace
Uses the Unicode whitespace property.
charIsHexDigit
Recognizes only ASCII 0–9, a–f, and A–F.
charIsLower
Returns True only for the Unicode LowercaseLetter general category.
charIsUpper
Returns True only for the Unicode UppercaseLetter general category.
charIsNewline
Returns True for line feed ('\n') or carriage return ('\r') and False
for other scalars.
Classification functions are logically O(1).
Case mapping
charToLower
Performs simple, locale-independent lowercase mapping. It returns one scalar and never expands a character into multiple values.
charToUpper
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.