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

Functions to introspect the Unicode script property for binaries (Strings) and codepoints.

The primary API is `script/1` which returns the script of a codepoint, or the list of scripts of a string.

The functions `fetch/1`, `get/1` and `count/1` provide introspection of the codepoint ranges belonging to a script. `scripts/0`, `known_scripts/0` and `aliases/0` return the underlying script data.

# `aliases`

Returns a map of aliases for Unicode scripts.

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

### Returns

* A map where the alias string is the key and the script name is the value.

### Examples

    iex> Unicode.Script.aliases() |> Map.get("ogam")
    :ogham

# `count`

Returns the count of characters in a given script.

Aliases are resolved by this function.

### Arguments

* `script` is any script name or alias, as an atom or string.

### Returns

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

* `:error` if the script is not known.

### Examples

    iex> Unicode.Script.count("mongolian")
    168

# `fetch`

Returns the Unicode codepoint ranges for a given script.

Aliases are resolved by this function.

### Arguments

* `script` is any script 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 script is not known.

### Examples

    iex> Unicode.Script.fetch(:ogham)
    {:ok, [{5760, 5788}]}

    iex> Unicode.Script.fetch(:invalid)
    :error

# `get`

Returns the Unicode codepoint ranges for a given script.

Aliases are resolved by this function.

### Arguments

* `script` is any script name or alias, as an atom or string.

### Returns

* A list of codepoint ranges as 2-tuples.

* `nil` if the script is not known.

### Examples

    iex> Unicode.Script.get(:ogham)
    [{5760, 5788}]

    iex> Unicode.Script.get(:invalid)
    nil

# `known_scripts`

Returns a list of known Unicode script names.

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

### Returns

* A list of atom script names.

### Examples

    iex> :latin in Unicode.Script.known_scripts()
    true

# `script`

Returns the script 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 script name is returned.

* For a binary, a list of the distinct script names of the codepoints in the binary is returned.

### Examples

    iex> Unicode.Script.script(?A)
    :latin

    iex> Unicode.Script.script("abc")
    [:latin]

# `scripts`

Returns the map of Unicode scripts.

### Returns

* A map where the script name is the key and a list of codepoint ranges as 2-tuples is the value.

### Examples

    iex> Unicode.Script.scripts() |> Map.get(:ogham)
    [{5760, 5788}]

---

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