HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduleunicode-data-0.9.0Haskell2010

Unicode.Char

This module provides APIs to access the Unicode character database (UCD) corresponding to Unicode Standard version 17.0.0.

This module re-exports several sub-modules under it. The sub-module structure under Unicode.Char is largely based on the "Property Index by Scope of Use" in Unicode® Standard Annex #44.

The Unicode.Char.* modules in turn depend on Unicode.Internal.Char.* modules which are programmatically generated from the Unicode standard's Unicode character database files. The module structure under Unicode.Internal.Char is largely based on the UCD text file names from which the properties are generated.

For the original UCD files used in this code please refer to the UCD section on the Unicode standard page. See https://www.unicode.org/reports/tr44/ to understand the contents and the format of the unicode database files.

  • 2 types
  • 48 values
valueisAscii :: Char -> Bool
#

Selects the first 128 characters of the Unicode character set, corresponding to the ASCII character set.

valueisLatin1 :: Char -> Bool
#

Selects the first 256 characters of the Unicode character set, corresponding to the ISO 8859-1 (Latin-1) character set.

The Unicode general category of the character.

This property is defined in the column 2 of the UnicodeData table.

This relies on the Enum instance of GeneralCategory, which must remain in the same order as the categories are presented in the Unicode standard.

Property
show (generalCategory c) == show (Data.Char.generalCategory c)
valuehangulFirst :: Int
#

Codepoint of the first pre-composed Hangul character.

valueisAlphabetic :: Char -> Bool
#

Returns True for alphabetic Unicode characters (lower-case, upper-case and title-case letters, plus letters of caseless scripts and modifiers letters).

Note: this function is not equivalent to isAlpha / isLetter:

valueisControl :: Char -> Bool
#

Selects control characters, which are the non-printing characters of the Latin-1 subset of Unicode.

This function returns True if its argument has the GeneralCategory Control.

Property
isControl c == Data.Char.isControl c
valueisHangul :: Char -> Bool
#

Determine if the given character is a precomposed Hangul syllable.

valueisHangulLV :: Char -> Bool
#

Determine if the given character is a Hangul LV syllable.

Note: this function requires a precomposed Hangul syllable but does not check it. Use isHangul to check the input character before passing it to isHangulLV.

valueisJamo :: Char -> Bool
#

Determine whether a character is a jamo L, V or T character.

valueisNoncharacter :: Char -> Bool
#

Returns True for any noncharacter.

A noncharacter is a code point that is permanently reserved for internal use (see definition D14 in the section 3.4 “Characters and Encoding” of the Unicode Standard).

Noncharacters consist of the values U+nFFFE and U+nFFFF (where n is from 0 to 10₁₆) and the values U+FDD0..U+FDEF.

valuejamoLIndex :: Char -> Maybe Int
#

Given a Unicode character, if it is a leading jamo, return its index in the list of leading jamo consonants, otherwise return Nothing.

valuejamoNCount :: Int
#

Total count of all jamo characters.

jamoNCount = jamoVCount * jamoTCount
valuejamoTFirst :: Int
#

The first trailing consonant jamo.

Note that jamoTFirst does not represent a valid T, it represents a missing T i.e. LV without a T. See comments under jamoTIndex .

valuejamoTIndex :: Char -> Maybe Int
#

Given a Unicode character, if it is a trailing jamo consonant, return its index in the list of trailing jamo consonants, otherwise return Nothing.

Note that index 0 is not a valid index for a trailing consonant. Index 0 corresponds to an LV syllable, without a T. See "Hangul Syllable Decomposition" in the Conformance chapter of the Unicode standard for more details.

valuejamoVIndex :: Char -> Maybe Int
#

Given a Unicode character, if it is a vowel jamo, return its index in the list of vowel jamo, otherwise return Nothing.

datadata CodePointType
#

Types of Code Points.

These classes are defined in the section 2.4 “Code Points and Characters” of the Unicode standard.

Constructors

Instances6Bounded, Enum, Eq, Ord, Show, Ix
datadata GeneralCategory
#

Unicode General Categories.

These classes are defined in the Unicode Character Database, part of the Unicode standard.

Note: the classes must be in the same order they are listed in the Unicode Standard, because some functions (e.g. generalCategory) rely on the Enum instance.

Constructors

Instances6Bounded, Enum, Eq, Ord, Show, Ix

Returns the full folded case mapping of a character if the character is changed, else nothing.

It uses the character property Case_Folding.

Returns the full lower case mapping of a character if the character is changed, else nothing.

It uses the character property Lowercase_Mapping.

Returns the full title case mapping of a character if the character is changed, else nothing.

It uses the character property Titlecase_Mapping.

valuetoCaseFoldString :: Char -> String
#

Convert a character to full folded case if defined, else to itself.

This function is mainly useful for performing caseless (also known as case insensitive) string comparisons.

A string x is a caseless match for a string y if and only if:

foldMap toCaseFoldString x == foldMap toCaseFoldString y

The result string may have more than one character, and may differ from applying toLowerString to the input string. For instance, “ﬓ” (U+FB13 Armenian small ligature men now) is case folded to the sequence “մ” (U+0574 Armenian small letter men) followed by “ն” (U+0576 Armenian small letter now), while “µ” (U+00B5 micro sign) is case folded to “μ” (U+03BC Greek small letter mu) instead of itself.

It uses the character property Case_Folding.

Property
toCaseFoldString c == foldMap toCaseFoldString (toCaseFoldString c)
valuetoLowerString :: Char -> String
#

Convert a character to full lower case if defined, else to itself.

The result string may have more than one character. For instance, “İ” (U+0130 Latin capital letter I with dot above) maps to the sequence: “i” (U+0069 Latin small letter I) followed by “ ̇” (U+0307 combining dot above).

It uses the character property Lowercase_Mapping.

See: toLower for simple lower case conversion.

Property
toLowerString c == foldMap toLowerString (toLowerString c)
valuetoTitleString :: Char -> String
#

Convert a character to full title case if defined, else to itself.

The result string may have more than one character. For instance, “fl” (U+FB02 Latin small ligature FL) is converted to the sequence: “F” (U+0046 Latin capital letter F) followed by “l” (U+006C Latin small letter L).

It uses the character property Titlecase_Mapping.

See: toTitle for simple title case conversion.

valuetoUpperString :: Char -> String
#

Convert a character to full upper case if defined, else to itself.

The result string may have more than one character. For instance, the German “ß” (U+00DF Eszett) maps to the two-letter sequence “SS”.

It uses the character property Uppercase_Mapping.

See: toUpper for simple upper case conversion.

Property
toUpperString c == foldMap toUpperString (toUpperString c)

Returns the full upper case mapping of a character if the character is changed, else nothing.

It uses the character property Uppercase_Mapping.

Utils

1 declaration
valueshowCodePoint :: Char -> ShowS
#

Show the code point of a character using the Unicode Standard convention: hexadecimal codepoint padded with zeros if inferior to 4 characters.

Example2 expressions
showCodePoint '\xf' """000F"showCodePoint '\x1ffff' """1FFFF"

Re-export from base

2 declarations
valueord :: Char -> Int
#

The Prelude.fromEnum method restricted to the type Char.

valuechr :: Int -> Char
#

The Prelude.toEnum method restricted to the type Char.