Unicode.IndicPositionalCategory (Unicode v2.1.0)

Copy Markdown View Source

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

The Indic_Positional_Category property describes the visual position of a dependent character relative to its base, for example :top, :bottom, :left, :right or :top_and_bottom. Codepoints to which it does not apply have the value :na (Not_Applicable).

The primary API is indic_positional_category/1 which returns the category of a codepoint, or the list of categories of a string.

Summary

Functions

Returns a map of aliases for Unicode indic positional categories.

Returns the count of the codepoints with a given indic positional category.

Returns the Unicode codepoint ranges for a given indic positional category.

Returns the Unicode codepoint ranges for a given indic positional category.

Returns the map of Unicode indic positional categories.

Returns the indic positional category of the given binary or codepoint.

Returns a list of known Unicode indic positional category names.

Functions

aliases()

Returns a map of aliases for Unicode indic positional categories.

Returns

  • A map where the alias string is the key and the indic positional category is the value.

Examples

iex> Unicode.IndicPositionalCategory.aliases() |> Map.get("top")
:top

count(indic_positional_category)

Returns the count of the codepoints with a given indic positional category.

Aliases are resolved by this function.

Arguments

  • indic_positional_category is any category name or alias, as an atom or string.

Returns

  • A non-negative integer count of the codepoints with the indic positional category.

  • :error if the indic positional category is not known.

Examples

iex> is_integer(Unicode.IndicPositionalCategory.count(:top))
true

fetch(indic_positional_category)

Returns the Unicode codepoint ranges for a given indic positional category.

Aliases are resolved by this function.

Arguments

  • indic_positional_category is any 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 indic positional category is not known.

Examples

iex> Unicode.IndicPositionalCategory.fetch(:top) |> elem(0)
:ok

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

get(indic_positional_category)

Returns the Unicode codepoint ranges for a given indic positional category.

Aliases are resolved by this function.

Arguments

  • indic_positional_category is any category name or alias, as an atom or string.

Returns

  • A list of codepoint ranges as 2-tuples.

  • nil if the indic positional category is not known.

Examples

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

indic_positional_categories()

Returns the map of Unicode indic positional categories.

Returns

  • A map where the indic positional category is the key and a list of codepoint ranges as 2-tuples is the value.

Examples

iex> :top in Map.keys(Unicode.IndicPositionalCategory.indic_positional_categories())
true

indic_positional_category(string)

Returns the indic positional category of 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 category atom is returned. Codepoints to which the property does not apply return :na.

  • For a binary, a list of the distinct categories of the codepoints in the binary is returned.

Examples

iex> Unicode.IndicPositionalCategory.indic_positional_category(0x0903)
:right

iex> Unicode.IndicPositionalCategory.indic_positional_category(?A)
:na

known_indic_positional_categories()

Returns a list of known Unicode indic positional category names.

Returns

  • A list of atom indic positional category names.

Examples

iex> :bottom in Unicode.IndicPositionalCategory.known_indic_positional_categories()
true