Functions to introspect the Unicode Numeric_Type property for binaries (Strings) and codepoints.
The Numeric_Type property classifies how a codepoint represents a number. The values are :decimal, :digit and :numeric; codepoints that are not numeric have the value :none.
The primary API is numeric_type/1 which returns the numeric type of a codepoint, or the list of numeric types of a string. See Unicode.NumericValue for the associated numeric values.
Summary
Functions
Returns a map of aliases for Unicode numeric types.
Returns the count of the codepoints with a given numeric type.
Returns the Unicode codepoint ranges for a given numeric type.
Returns the Unicode codepoint ranges for a given numeric type.
Returns a list of known Unicode numeric type names.
Returns the numeric type of the given binary or codepoint.
Returns the map of Unicode numeric types.
Functions
Returns a map of aliases for Unicode numeric types.
Returns
- A map where the alias string is the key and the numeric type is the value.
Examples
iex> Unicode.NumericType.aliases() |> Map.get("de")
:decimal
Returns the count of the codepoints with a given numeric type.
Aliases are resolved by this function.
Arguments
numeric_typeis any numeric type name or alias, as an atom or string.
Returns
A non-negative integer count of the codepoints with the numeric type.
:errorif the numeric type is not known.
Examples
iex> Unicode.NumericType.count(:decimal)
770
Returns the Unicode codepoint ranges for a given numeric type.
Aliases are resolved by this function.
Arguments
numeric_typeis any numeric 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 numeric type is not known.
Examples
iex> Unicode.NumericType.fetch(:decimal) |> elem(0)
:ok
iex> Unicode.NumericType.fetch(:invalid)
:error
Returns the Unicode codepoint ranges for a given numeric type.
Aliases are resolved by this function.
Arguments
numeric_typeis any numeric type name or alias, as an atom or string.
Returns
A list of codepoint ranges as 2-tuples.
nilif the numeric type is not known.
Examples
iex> Unicode.NumericType.get(:invalid)
nil
Returns a list of known Unicode numeric type names.
Returns
- A list of atom numeric type names.
Examples
iex> :decimal in Unicode.NumericType.known_numeric_types()
true
Returns the numeric 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 numeric type atom is returned. Non-numeric codepoints return
:none.For a binary, a list of the distinct numeric types of the codepoints in the binary is returned.
Examples
iex> Unicode.NumericType.numeric_type(?1)
:decimal
iex> Unicode.NumericType.numeric_type(?A)
:none
iex> Unicode.NumericType.numeric_type(?½)
:numeric
Returns the map of Unicode numeric types.
Returns
- A map where the numeric type is the key and a list of codepoint ranges as 2-tuples is the value.
Examples
iex> Unicode.NumericType.numeric_types() |> Map.keys() |> Enum.sort()
[:decimal, :digit, :numeric]