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

Functions to introspect the Unicode canonical combining class property for binaries (Strings) and codepoints.

The primary API is `combining_class/1` which returns the canonical combining class of a codepoint, or the list of canonical combining classes of a string.

The functions `fetch/1`, `get/1` and `count/1` provide introspection of the codepoint ranges belonging to a combining class. `combining_classes/0`, `known_combining_classes/0` and `aliases/0` return the underlying combining class data.

# `aliases`

Returns a map of aliases for Unicode canonical combining classes.

An alias is an alternative name for referring to a class. Aliases are resolved by the `fetch/1` and `get/1` functions.

### Returns

* A map where the alias string is the key and the combining class number is the value.

### Examples

    iex> Unicode.CanonicalCombiningClass.aliases() |> Map.get("above")
    230

# `combining_class`

Returns the canonical combining class(es) 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 combining class number is returned.

* For a binary, a list of the distinct combining class numbers of the codepoints in the binary is returned.

### Examples

    iex> Unicode.CanonicalCombiningClass.combining_class(0x0301)
    230

    iex> Unicode.CanonicalCombiningClass.combining_class("abc")
    [0]

# `combining_classes`

Returns the map of Unicode canonical combining classes.

### Returns

* A map where the combining class number is the key and a list of codepoint ranges as 2-tuples is the value.

### Examples

    iex> Unicode.CanonicalCombiningClass.combining_classes() |> Map.get(214)
    [{7630, 7630}]

# `count`

Returns the count of characters in a given canonical combining class.

Aliases are resolved by this function.

### Arguments

* `class` is any combining class number, or a class alias as a string.

### Returns

* A non-negative integer count of the codepoints in the combining class.

* `:error` if the combining class is not known.

### Examples

    iex> Unicode.CanonicalCombiningClass.count(230)
    546

# `fetch`

Returns the Unicode codepoint ranges for a given canonical combining class.

Aliases are resolved by this function.

### Arguments

* `combining_class` is any combining class number, or a class alias as a string.

### Returns

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

* `:error` if the combining class is not known.

### Examples

    iex> Unicode.CanonicalCombiningClass.fetch(214)
    {:ok, [{7630, 7630}]}

    iex> Unicode.CanonicalCombiningClass.fetch(999)
    :error

# `get`

Returns the Unicode codepoint ranges for a given canonical combining class.

Aliases are resolved by this function.

### Arguments

* `combining_class` is any combining class number, or a class alias as a string.

### Returns

* A list of codepoint ranges as 2-tuples.

* `nil` if the combining class is not known.

### Examples

    iex> Unicode.CanonicalCombiningClass.get(214)
    [{7630, 7630}]

    iex> Unicode.CanonicalCombiningClass.get(999)
    nil

# `known_combining_classes`

Returns a list of known Unicode canonical combining class numbers.

This function does not return the names of any class aliases.

### Returns

* A list of integer combining class numbers.

### Examples

    iex> 230 in Unicode.CanonicalCombiningClass.known_combining_classes()
    true

---

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