Character data: the Unicode Character Database properties of single codepoints.
Every function takes a codepoint, an integer from 0 to 0x10FFFF, such as ?A or 0x1F600.
Use String.to_charlist/1 or String.codepoints/1 to get the codepoints of a string.
Values that the UCD names, such as categories, scripts, blocks, and property values, are atoms
made from their long names: :uppercase_letter, :latin, :basic_latin, :alphabetic.
Examples
iex> Mojibake.Char.category(?A)
:uppercase_letter
iex> Mojibake.Char.script(?Ω)
:greek
iex> Mojibake.Char.property?(?7, :ascii_hex_digit)
true
Summary
Types
A Bidi_Class value: :left_to_right, :right_to_left, :arabic_letter, :european_number,
:european_separator, :european_terminator, :arabic_number, :common_separator,
:nonspacing_mark, :boundary_neutral, :paragraph_separator, :segment_separator,
:white_space, :other_neutral, :left_to_right_embedding, :left_to_right_override,
:right_to_left_embedding, :right_to_left_override, :pop_directional_format,
:left_to_right_isolate, :right_to_left_isolate, :first_strong_isolate, or
:pop_directional_isolate.
A General_Category value, such as :uppercase_letter, or :unassigned. See
category_abbreviation/1 for the two-letter form.
A codepoint, 0 to 0x10FFFF.
A Decomposition_Type value other than None: :canonical, or one of the compatibility types
:circle, :compat, :final, :font, :fraction, :initial, :isolated, :medial,
:narrow, :no_break, :small, :square, :sub, :super, :vertical, and :wide.
A Numeric_Value: an integer, or {numerator, denominator} for a fraction such as ½.
Functions
The Bidi_Class of codepoint in UnicodeData.txt, or nil if it is unassigned.
Return true if codepoint is mirrored in bidirectional text (Bidi_Mirrored), such as (.
The block of codepoint, or nil if it is in no block. See Mojibake.Block.
The General_Category of codepoint, :unassigned if it has none. Noncharacters, such as
U+FFFF, are :unassigned.
The two-letter General_Category abbreviation of codepoint, such as "Lu", or "Cn" if it is
unassigned.
Return true if codepoint is a CJK unified ideograph in one of the extension blocks.
Return true if codepoint is a CJK unified ideograph, in the main block or an extension.
Return true if codepoint is a combining character (a mark: Mn, Mc, or Me).
The Canonical_Combining_Class of codepoint, 0 for starters and unassigned codepoints.
The Decomposition_Type of codepoint, or nil if it has no decomposition.
The East_Asian_Width of codepoint (UAX #11): :ambiguous, :fullwidth, :halfwidth,
:neutral, :narrow, or :wide. Codepoints that EastAsianWidth.txt does not list are
:neutral.
The emoji properties of codepoint in emoji-data.txt, as a map of booleans
Return true if codepoint is graphic: a letter, mark, number, punctuation, symbol, or space.
Return everything UnicodeData.txt says about codepoint, or nil if it is unassigned.
The character name of codepoint, or nil if it is unassigned. Characters without a name of
their own, such as controls, have the empty string.
The Numeric_Type of codepoint: :decimal for decimal digits, :digit for other digits such
as superscripts, :numeric for other numbers such as fractions and Roman numerals, or nil.
The Numeric_Value of codepoint: an integer, {numerator, denominator} for a fraction, or
nil if it is not a number.
The plane of codepoint, 0 to 16. See Mojibake.Plane.
The value of the enumerated property for codepoint, or nil if codepoint has none. See
Mojibake.Property.values/1 for the values. Raises ArgumentError if property is not an
enumerated property.
Return the value of the binary property for codepoint. See Mojibake.Property for the
properties. Raises ArgumentError if property is not a binary property.
The Script of codepoint, :unknown if it has none. See Mojibake.Script.
The Script_Extensions of codepoint: the scripts it is used with. For most codepoints, this is
[script(codepoint)].
The simple lowercase mapping of codepoint, or codepoint itself.
The simple titlecase mapping of codepoint, or codepoint itself.
The simple uppercase mapping of codepoint: the single codepoint UnicodeData.txt gives, or
codepoint itself. Mojibake.upcase/2 applies the full mappings, such as "ß" to "SS".
Types
@type bidi_class() :: atom()
A Bidi_Class value: :left_to_right, :right_to_left, :arabic_letter, :european_number,
:european_separator, :european_terminator, :arabic_number, :common_separator,
:nonspacing_mark, :boundary_neutral, :paragraph_separator, :segment_separator,
:white_space, :other_neutral, :left_to_right_embedding, :left_to_right_override,
:right_to_left_embedding, :right_to_left_override, :pop_directional_format,
:left_to_right_isolate, :right_to_left_isolate, :first_strong_isolate, or
:pop_directional_isolate.
@type category() :: atom()
A General_Category value, such as :uppercase_letter, or :unassigned. See
category_abbreviation/1 for the two-letter form.
@type codepoint() :: non_neg_integer()
A codepoint, 0 to 0x10FFFF.
@type decomposition_type() :: atom()
A Decomposition_Type value other than None: :canonical, or one of the compatibility types
:circle, :compat, :final, :font, :fraction, :initial, :isolated, :medial,
:narrow, :no_break, :small, :square, :sub, :super, :vertical, and :wide.
@type numeric_value() :: integer() | {integer(), pos_integer()}
A Numeric_Value: an integer, or {numerator, denominator} for a fraction such as ½.
@type t() :: %Mojibake.Char{ bidi_class: bidi_class(), bidi_mirrored: boolean(), category: category(), codepoint: codepoint(), combining_class: 0..254, decomposition_type: decomposition_type() | nil, lowercase: codepoint(), name: String.t(), numeric_type: :decimal | :digit | :numeric | nil, numeric_value: numeric_value() | nil, titlecase: codepoint(), uppercase: codepoint() }
What info/1 returns.
Functions
@spec bidi_class(codepoint()) :: bidi_class() | nil
The Bidi_Class of codepoint in UnicodeData.txt, or nil if it is unassigned.
Examples
iex> Mojibake.Char.bidi_class(?A)
:left_to_right
iex> Mojibake.Char.bidi_class(0x05D0)
:right_to_left
Return true if codepoint is mirrored in bidirectional text (Bidi_Mirrored), such as (.
Examples
iex> Mojibake.Char.bidi_mirrored?(?()
true
@spec block(codepoint()) :: Mojibake.Block.t() | nil
The block of codepoint, or nil if it is in no block. See Mojibake.Block.
Examples
iex> Mojibake.Char.block(?A)
:basic_latin
iex> Mojibake.Char.block(0x1F600)
:emoticons
The General_Category of codepoint, :unassigned if it has none. Noncharacters, such as
U+FFFF, are :unassigned.
Examples
iex> Mojibake.Char.category(?a)
:lowercase_letter
iex> Mojibake.Char.category(0x0378)
:unassigned
The two-letter General_Category abbreviation of codepoint, such as "Lu", or "Cn" if it is
unassigned.
Examples
iex> Mojibake.Char.category_abbreviation(?A)
"Lu"
Return true if codepoint is a CJK unified ideograph in one of the extension blocks.
Examples
iex> Mojibake.Char.cjk_extension_ideograph?(0x20000)
true
iex> Mojibake.Char.cjk_extension_ideograph?(0x4E00)
false
Return true if codepoint is a CJK unified ideograph, in the main block or an extension.
Examples
iex> Mojibake.Char.cjk_ideograph?(0x4E00)
true
Return true if codepoint is a combining character (a mark: Mn, Mc, or Me).
Examples
iex> Mojibake.Char.combining?(0x0301)
true
@spec combining_class(codepoint()) :: 0..254
The Canonical_Combining_Class of codepoint, 0 for starters and unassigned codepoints.
Examples
iex> Mojibake.Char.combining_class(0x0301)
230
@spec decomposition_type(codepoint()) :: decomposition_type() | nil
The Decomposition_Type of codepoint, or nil if it has no decomposition.
Examples
iex> Mojibake.Char.decomposition_type(?é)
:canonical
iex> Mojibake.Char.decomposition_type(?fi)
:compat
iex> Mojibake.Char.decomposition_type(?a)
nil
The East_Asian_Width of codepoint (UAX #11): :ambiguous, :fullwidth, :halfwidth,
:neutral, :narrow, or :wide. Codepoints that EastAsianWidth.txt does not list are
:neutral.
Examples
iex> Mojibake.Char.east_asian_width(?A)
:narrow
iex> Mojibake.Char.east_asian_width(0x4E00)
:wide
@spec emoji_properties(codepoint()) :: %{ emoji: boolean(), presentation: boolean(), modifier: boolean(), modifier_base: boolean(), component: boolean(), extended_pictographic: boolean() }
The emoji properties of codepoint in emoji-data.txt, as a map of booleans:
:emoji- Emoji:presentation- Emoji_Presentation, shown as an emoji by default:modifier- Emoji_Modifier, a skin-tone modifier:modifier_base- Emoji_Modifier_Base, takes a skin-tone modifier:component- Emoji_Component, used inside emoji sequences:extended_pictographic- Extended_Pictographic
Mojibake.Emoji classifies whole emoji sequences.
Examples
iex> Mojibake.Char.emoji_properties(0x1F600)
%{
emoji: true,
presentation: true,
modifier: false,
modifier_base: false,
component: false,
extended_pictographic: true
}
Return true if codepoint is graphic: a letter, mark, number, punctuation, symbol, or space.
Examples
iex> Mojibake.Char.graphic?(?a)
true
iex> Mojibake.Char.graphic?(0x0007)
false
Return everything UnicodeData.txt says about codepoint, or nil if it is unassigned.
Noncharacters, such as U+FFFF, are nil too.
Codepoints whose data UnicodeData.txt gives as a range, such as CJK ideographs and Hangul
syllables, have their derived names.
uppercase, lowercase, and titlecase are the simple (single-codepoint) case mappings, and
are the codepoint itself when it has none.
Examples
iex> Mojibake.Char.info(?½)
%Mojibake.Char{
codepoint: 0xBD,
name: "VULGAR FRACTION ONE HALF",
category: :other_number,
combining_class: 0,
bidi_class: :other_neutral,
bidi_mirrored: false,
decomposition_type: :fraction,
numeric_type: :numeric,
numeric_value: {1, 2},
uppercase: 0xBD,
lowercase: 0xBD,
titlecase: 0xBD
}
iex> Mojibake.Char.info(0x0378)
nil
The character name of codepoint, or nil if it is unassigned. Characters without a name of
their own, such as controls, have the empty string.
Needs the :names feature; raises Mojibake.Error with reason :feature_not_enabled when the
package is built without it. Hangul syllable names are available from
Mojibake.Hangul.syllable_name/1 either way.
Examples
iex> Mojibake.Char.name(?A)
"LATIN CAPITAL LETTER A"
iex> Mojibake.Char.name(0x4E00)
"CJK UNIFIED IDEOGRAPH-4E00"
@spec numeric_type(codepoint()) :: :decimal | :digit | :numeric | nil
The Numeric_Type of codepoint: :decimal for decimal digits, :digit for other digits such
as superscripts, :numeric for other numbers such as fractions and Roman numerals, or nil.
Examples
iex> Mojibake.Char.numeric_type(?7)
:decimal
iex> Mojibake.Char.numeric_type(?²)
:digit
iex> Mojibake.Char.numeric_type(?Ⅻ)
:numeric
@spec numeric_value(codepoint()) :: numeric_value() | nil
The Numeric_Value of codepoint: an integer, {numerator, denominator} for a fraction, or
nil if it is not a number.
Examples
iex> Mojibake.Char.numeric_value(?7)
7
iex> Mojibake.Char.numeric_value(?¾)
{3, 4}
iex> Mojibake.Char.numeric_value(?Ⅻ)
12
iex> Mojibake.Char.numeric_value(?a)
nil
@spec plane(codepoint()) :: Mojibake.Plane.t()
The plane of codepoint, 0 to 16. See Mojibake.Plane.
Examples
iex> Mojibake.Char.plane(0x1F600)
1
@spec property(codepoint(), Mojibake.Property.t()) :: atom() | nil
The value of the enumerated property for codepoint, or nil if codepoint has none. See
Mojibake.Property.values/1 for the values. Raises ArgumentError if property is not an
enumerated property.
Examples
iex> Mojibake.Char.property(?A, :line_break)
:alphabetic
iex> Mojibake.Char.property(?,, :word_break)
:mid_num
iex> Mojibake.Char.property(0x0627, :joining_type)
:right_joining
@spec property?(codepoint(), Mojibake.Property.t()) :: boolean()
Return the value of the binary property for codepoint. See Mojibake.Property for the
properties. Raises ArgumentError if property is not a binary property.
Examples
iex> Mojibake.Char.property?(?\s, :white_space)
true
iex> Mojibake.Char.property?(?a, :uppercase)
false
@spec script(codepoint()) :: Mojibake.Script.t()
The Script of codepoint, :unknown if it has none. See Mojibake.Script.
Examples
iex> Mojibake.Char.script(?A)
:latin
iex> Mojibake.Char.script(?1)
:common
@spec script_extensions(codepoint()) :: [Mojibake.Script.t()]
The Script_Extensions of codepoint: the scripts it is used with. For most codepoints, this is
[script(codepoint)].
Examples
iex> Mojibake.Char.script_extensions(?A)
[:latin]
iex> Mojibake.Char.script_extensions(0x3001)
[:bopomofo, :hangul, :han, :hiragana, :katakana, :mongolian, :yi]
The simple lowercase mapping of codepoint, or codepoint itself.
Examples
iex> Mojibake.Char.simple_downcase(?Ω)
?ω
The simple titlecase mapping of codepoint, or codepoint itself.
Examples
iex> Mojibake.Char.simple_titlecase(?dž)
?Dž
The simple uppercase mapping of codepoint: the single codepoint UnicodeData.txt gives, or
codepoint itself. Mojibake.upcase/2 applies the full mappings, such as "ß" to "SS".
Examples
iex> Mojibake.Char.simple_upcase(?a)
?A
iex> Mojibake.Char.simple_upcase(?ß)
?ß