# `Unicode.Script`
[🔗](https://github.com/elixir-unicode/unicode/blob/v2.2.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.

# `t`

```elixir
@type t() ::
  :zanabazar_square
  | :yi
  | :yezidi
  | :warang_citi
  | :wancho
  | :vithkuqi
  | :vai
  | :unknown
  | :ugaritic
  | :tulu_tigalari
  | :toto
  | :tolong_siki
  | :todhri
  | :tirhuta
  | :tifinagh
  | :tibetan
  | :thai
  | :thaana
  | :telugu
  | :tangut
  | :tangsa
  | :tamil
  | :takri
  | :tai_yo
  | :tai_viet
  | :tai_tham
  | :tai_le
  | :tagbanwa
  | :tagalog
  | :syriac
  | :syloti_nagri
  | :sunuwar
  | :sundanese
  | :soyombo
  | :sora_sompeng
  | :sogdian
  | :sinhala
  | :signwriting
  | :sidetic
  | :siddham
  | :shavian
  | :sharada
  | :seal
  | :saurashtra
  | :samaritan
  | :runic
  | :rejang
  | :psalter_pahlavi
  | :proto_cuneiform
  | :phoenician
  | :phags_pa
  | :pau_cin_hau
  | :palmyrene
  | :pahawh_hmong
  | :osmanya
  | :osage
  | :oriya
  | :old_uyghur
  | :old_turkic
  | :old_south_arabian
  | :old_sogdian
  | :old_persian
  | :old_permic
  | :old_north_arabian
  | :old_italic
  | :old_hungarian
  | :ol_onal
  | :ol_chiki
  | :ogham
  | :nyiakeng_puachue_hmong
  | :nushu
  | :nko
  | :newa
  | :new_tai_lue
  | :nandinagari
  | :nag_mundari
  | :nabataean
  | :myanmar
  | :multani
  | :mro
  | :mongolian
  | :modi
  | :miao
  | :meroitic_hieroglyphs
  | :meroitic_cursive
  | :mende_kikakui
  | :meetei_mayek
  | :medefaidrin
  | :masaram_gondi
  | :marchen
  | :manichaean
  | :mandaic
  | :malayalam
  | :makasar
  | :mahajani
  | :lydian
  | :lycian
  | :lisu
  | :linear_b
  | :linear_a
  | :limbu
  | :lepcha
  | :latin
  | :lao
  | :kirat_rai
  | :khudawadi
  | :khojki
  | :khmer
  | :khitan_small_script
  | :kharoshthi
  | :kayah_li
  | :kawi
  | :katakana
  | :kannada
  | :kaithi
  | :jurchen
  | :javanese
  | :inscriptional_parthian
  | :inscriptional_pahlavi
  | :inherited
  | :imperial_aramaic
  | :hiragana
  | :hebrew
  | :hatran
  | :hanunoo
  | :hanifi_rohingya
  | :hangul
  | :han
  | :gurung_khema
  | :gurmukhi
  | :gunjala_gondi
  | :gujarati
  | :greek
  | :grantha
  | :gothic
  | :glagolitic
  | :georgian
  | :garay
  | :ethiopic
  | :elymaic
  | :elbasan
  | :egyptian_hieroglyphs
  | :duployan
  | :dogra
  | :dives_akuru
  | :devanagari
  | :deseret
  | :cyrillic
  | :cypro_minoan
  | :cypriot
  | :cuneiform
  | :coptic
  | :common
  | :chorasmian
  | :cherokee
  | :cham
  | :chakma
  | :caucasian_albanian
  | :carian
  | :canadian_aboriginal
  | :buhid
  | :buginese
  | :braille
  | :brahmi
  | :bopomofo
  | :bhaiksuki
  | :beria_erfe
  | :bengali
  | :batak
  | :bassa_vah
  | :bamum
  | :balinese
  | :avestan
  | :armenian
  | :arabic
  | :anatolian_hieroglyphs
  | :ahom
  | :adlam
```

A Unicode script name.

Generated from the script data at compile time, so it tracks each Unicode release automatically
rather than being hand-maintained.

# `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*
