Functions to introspect the Unicode Decomposition_Type property for binaries (Strings) and codepoints.
The Decomposition_Type property classifies the kind of decomposition mapping a codepoint has, for example :canonical, :compat, :font, :circle or :nobreak. Codepoints with no decomposition mapping have the value :none.
The primary API is decomposition_type/1 which returns the decomposition type of a codepoint, or the list of decomposition types of a string.
Summary
Functions
Returns a map of aliases for Unicode decomposition types.
Returns the count of the codepoints with a given decomposition type.
Returns the decomposition type of the given binary or codepoint.
Returns the map of Unicode decomposition types.
Returns the Unicode codepoint ranges for a given decomposition type.
Returns the Unicode codepoint ranges for a given decomposition type.
Returns a list of known Unicode decomposition type names.
Functions
Returns a map of aliases for Unicode decomposition types.
Returns
- A map where the alias string is the key and the decomposition type is the value.
Examples
iex> Unicode.DecompositionType.aliases() |> Map.get("can")
:canonical
Returns the count of the codepoints with a given decomposition type.
Aliases are resolved by this function.
Arguments
decomposition_typeis any decomposition type name or alias, as an atom or string.
Returns
A non-negative integer count of the codepoints with the decomposition type.
:errorif the decomposition type is not known.
Examples
iex> is_integer(Unicode.DecompositionType.count(:canonical))
true
Returns the decomposition type of the given binary or codepoint.
Arguments
string_or_codepointis either a binary (String) or a codepoint in the range0..0x10FFFF.
Returns
For a codepoint, a single decomposition type atom is returned. Codepoints with no decomposition mapping return
:none.For a binary, a list of the distinct decomposition types of the codepoints in the binary is returned.
Examples
iex> Unicode.DecompositionType.decomposition_type(0x00A0)
:nobreak
iex> Unicode.DecompositionType.decomposition_type(?A)
:none
Returns the map of Unicode decomposition types.
Returns
- A map where the decomposition type is the key and a list of codepoint ranges as 2-tuples is the value.
Examples
iex> :canonical in Map.keys(Unicode.DecompositionType.decomposition_types())
true
Returns the Unicode codepoint ranges for a given decomposition type.
Aliases are resolved by this function.
Arguments
decomposition_typeis any decomposition type name or alias, as an atom or string.
Returns
{:ok, range_list}whererange_listis a list of codepoint ranges as 2-tuples.:errorif the decomposition type is not known.
Examples
iex> Unicode.DecompositionType.fetch(:canonical) |> elem(0)
:ok
iex> Unicode.DecompositionType.fetch(:invalid)
:error
Returns the Unicode codepoint ranges for a given decomposition type.
Aliases are resolved by this function.
Arguments
decomposition_typeis any decomposition type name or alias, as an atom or string.
Returns
A list of codepoint ranges as 2-tuples.
nilif the decomposition type is not known.
Examples
iex> Unicode.DecompositionType.get(:invalid)
nil
Returns a list of known Unicode decomposition type names.
Returns
- A list of atom decomposition type names.
Examples
iex> :compat in Unicode.DecompositionType.known_decomposition_types()
true