# `Unicode.EastAsianWidth`
[🔗](https://github.com/elixir-unicode/unicode/blob/v2.0.0/lib/unicode/property/east_asia_width.ex#L1)

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.

# `aliases`

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

# `count`

Returns the count of characters in a given east asian width category.

Aliases are resolved by this function.

### Arguments

* `east_asian_width_category` is 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.

* `:error` if the east asian width category is not known.

### Examples

    iex> Unicode.EastAsianWidth.count(:f)
    104

# `east_asian_width_categories`

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}]

# `east_asian_width_category`

Returns the east asian width category name(s) for the given binary or codepoint.

### Arguments

* `string_or_codepoint` is either a binary (String) or a codepoint in the range `0..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]

# `fetch`

Returns the Unicode codepoint ranges for a given east asian width category.

Aliases are resolved by this function.

### Arguments

* `east_asian_width_category` is any east asian width category name or alias, as an atom or string.

### Returns

* `{:ok, range_list}` where `range_list` is a list of codepoint ranges as 2-tuples.

* `:error` if 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

# `get`

Returns the Unicode codepoint ranges for a given east asian width category.

Aliases are resolved by this function.

### Arguments

* `east_asian_width_category` is any east asian width category name or alias, as an atom or string.

### Returns

* A list of codepoint ranges as 2-tuples.

* `nil` if 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

# `known_east_asian_width_categories`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
