Unicode.JoiningGroup (Unicode v2.2.0)

Copy Markdown View Source

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

The Joining_Group property groups Arabic and Syriac letters that share the same shaping behaviour, for example :beh, :alaph or :teh_marbuta. Codepoints that are not cursively joined have the value :no_joining_group.

The primary API is joining_group/1 which returns the joining group of a codepoint, or the list of joining groups of a string. This complements Unicode.JoiningType.

Summary

Functions

Returns a map of aliases for Unicode joining groups.

Returns the count of the codepoints in a given joining group.

Returns the Unicode codepoint ranges for a given joining group.

Returns the Unicode codepoint ranges for a given joining group.

Returns the joining group of the given binary or codepoint.

Returns the map of Unicode joining groups.

Returns a list of known Unicode joining group names.

Functions

aliases()

Returns a map of aliases for Unicode joining groups.

Returns

  • A map where the alias string is the key and the joining group is the value.

Examples

iex> Unicode.JoiningGroup.aliases() |> Map.get("beh")
:beh

count(joining_group)

Returns the count of the codepoints in a given joining group.

Aliases are resolved by this function.

Arguments

  • joining_group is any joining group name or alias, as an atom or string.

Returns

  • A non-negative integer count of the codepoints in the joining group.

  • :error if the joining group is not known.

Examples

iex> is_integer(Unicode.JoiningGroup.count(:beh))
true

fetch(joining_group)

Returns the Unicode codepoint ranges for a given joining group.

Aliases are resolved by this function.

Arguments

  • joining_group is any joining group 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 joining group is not known.

Examples

iex> Unicode.JoiningGroup.fetch(:beh) |> elem(0)
:ok

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

get(joining_group)

Returns the Unicode codepoint ranges for a given joining group.

Aliases are resolved by this function.

Arguments

  • joining_group is any joining group name or alias, as an atom or string.

Returns

  • A list of codepoint ranges as 2-tuples.

  • nil if the joining group is not known.

Examples

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

joining_group(string)

Returns the joining group 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 joining group atom is returned. Codepoints that are not cursively joined return :no_joining_group.

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

Examples

iex> Unicode.JoiningGroup.joining_group(0x0628)
:beh

iex> Unicode.JoiningGroup.joining_group(?A)
:no_joining_group

joining_groups()

Returns the map of Unicode joining groups.

Returns

  • A map where the joining group is the key and a list of codepoint ranges as 2-tuples is the value.

Examples

iex> :beh in Map.keys(Unicode.JoiningGroup.joining_groups())
true

known_joining_groups()

Returns a list of known Unicode joining group names.

Returns

  • A list of atom joining group names.

Examples

iex> :alaph in Unicode.JoiningGroup.known_joining_groups()
true