Skip to main content

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

charToUInt32 :: Char -> UInt32.

Returns the scalar's numeric Unicode value. This is logically O(1).

charFromUInt32

charFromUInt32 :: UInt32 -> Maybe(Char).

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

charIsAlpha :: Char -> Bool.

Returns True for Unicode characters in the UppercaseLetter, LowercaseLetter, TitlecaseLetter, ModifierLetter, or OtherLetter general category.

charIsAlphaNum

charIsAlphaNum :: Char -> Bool.

Returns True for any category accepted by charIsAlpha, plus DecimalNumber, LetterNumber, and OtherNumber.

charIsDigit

charIsDigit :: Char -> Bool.

Uses the Unicode digit property, not only ASCII 09.

charIsSpace

charIsSpace :: Char -> Bool.

Uses the Unicode whitespace property.

charIsHexDigit

charIsHexDigit :: Char -> Bool.

Recognizes only ASCII 09, af, and AF.

charIsLower

charIsLower :: Char -> Bool.

Returns True only for the Unicode LowercaseLetter general category.

charIsUpper

charIsUpper :: Char -> Bool.

Returns True only for the Unicode UppercaseLetter general category.

charIsNewline

charIsNewline :: Char -> Bool.

Returns True for line feed ('\n') or carriage return ('\r') and False for other scalars.

Classification functions are logically O(1).

Case mapping

charToLower

charToLower :: Char -> Char.

Performs simple, locale-independent lowercase mapping. It returns one scalar and never expands a character into multiple values.

charToUpper

charToUpper :: Char -> Char.

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.