Functions to introspect the Unicode east asian width property for binaries (Strings) and codepoints.
The primary API is east_asian_width_category/1 which returns the east asian width category of a codepoint, or the list of east asian width categories of a string.
The functions fetch/1, get/1 and count/1 provide introspection of the codepoint ranges belonging to an east asian width category. east_asian_width_categories/0, known_east_asian_width_categories/0 and aliases/0 return the underlying east asian width data.
Summary
Functions
Returns a map of aliases for Unicode east asian width categories.
Returns the count of characters in a given east asian width category.
Returns the map of Unicode east asian width categories.
Returns the east asian width category name(s) for the given binary or codepoint.
Returns the Unicode codepoint ranges for a given east asian width category.
Returns the Unicode codepoint ranges for a given east asian width category.
Returns a list of known Unicode east asian width category names.
Functions
Returns a map of aliases for Unicode east asian width categories.
An alias is an alternative name for referring to an east asian width category. Aliases are resolved by the fetch/1 and get/1 functions.
Returns
- A map where the alias string is the key and the east asian width category name is the value.
Examples
iex> Unicode.EastAsianWidth.aliases() |> Map.get("fullwidth")
:f
Returns the count of characters in a given east asian width category.
Aliases are resolved by this function.
Arguments
east_asian_width_categoryis any east asian width category name or alias, as an atom or string.
Returns
A non-negative integer count of the codepoints in the east asian width category.
:errorif the east asian width category is not known.
Examples
iex> Unicode.EastAsianWidth.count(:f)
104
Returns the map of Unicode east asian width categories.
Returns
- A map where the east asian width category name is the key and a list of codepoint ranges as 2-tuples is the value.
Examples
iex> Unicode.EastAsianWidth.east_asian_width_categories() |> Map.get(:f)
[{12288, 12288}, {65281, 65376}, {65504, 65510}]
Returns the east asian width category name(s) for 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 east asian width category name is returned.
For a binary, a list of the distinct east asian width category names of the codepoints in the binary is returned.
Examples
iex> Unicode.EastAsianWidth.east_asian_width_category(0xFF01)
:f
iex> Unicode.EastAsianWidth.east_asian_width_category("abc")
[:na]
Returns the Unicode codepoint ranges for a given east asian width category.
Aliases are resolved by this function.
Arguments
east_asian_width_categoryis any east asian width category name or alias, as an atom or string.
Returns
{:ok, range_list}whererange_listis a list of codepoint ranges as 2-tuples.:errorif the east asian width category is not known.
Examples
iex> Unicode.EastAsianWidth.fetch(:f)
{:ok, [{12288, 12288}, {65281, 65376}, {65504, 65510}]}
iex> Unicode.EastAsianWidth.fetch(:invalid)
:error
Returns the Unicode codepoint ranges for a given east asian width category.
Aliases are resolved by this function.
Arguments
east_asian_width_categoryis any east asian width category name or alias, as an atom or string.
Returns
A list of codepoint ranges as 2-tuples.
nilif the east asian width category is not known.
Examples
iex> Unicode.EastAsianWidth.get(:f)
[{12288, 12288}, {65281, 65376}, {65504, 65510}]
iex> Unicode.EastAsianWidth.get(:invalid)
nil
Returns a list of known Unicode east asian width category names.
This function does not return the names of any east asian width category aliases.
Returns
- A list of atom east asian width category names.
Examples
iex> :na in Unicode.EastAsianWidth.known_east_asian_width_categories()
true