Unicode.HangulSyllableType (Unicode v2.1.0)

Copy Markdown View Source

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

The Hangul_Syllable_Type property classifies Hangul jamo and precomposed syllables. The values are :l (Leading_Jamo), :v (Vowel_Jamo), :t (Trailing_Jamo), :lv (LV_Syllable) and :lvt (LVT_Syllable). Codepoints that are not Hangul have the value :na (Not_Applicable).

The primary API is hangul_syllable_type/1 which returns the type of a codepoint, or the list of types of a string.

Summary

Functions

Returns a map of aliases for Unicode hangul syllable types.

Returns the count of the codepoints with a given hangul syllable type.

Returns the Unicode codepoint ranges for a given hangul syllable type.

Returns the Unicode codepoint ranges for a given hangul syllable type.

Returns the hangul syllable type of the given binary or codepoint.

Returns the map of Unicode hangul syllable types.

Returns a list of known Unicode hangul syllable type names.

Functions

aliases()

Returns a map of aliases for Unicode hangul syllable types.

Returns

  • A map where the alias string is the key and the hangul syllable type is the value.

Examples

iex> Unicode.HangulSyllableType.aliases() |> Map.get("leadingjamo")
:l

count(hangul_syllable_type)

Returns the count of the codepoints with a given hangul syllable type.

Aliases are resolved by this function.

Arguments

  • hangul_syllable_type is any type name or alias, as an atom or string.

Returns

  • A non-negative integer count of the codepoints with the hangul syllable type.

  • :error if the hangul syllable type is not known.

Examples

iex> Unicode.HangulSyllableType.count(:lv)
399

fetch(hangul_syllable_type)

Returns the Unicode codepoint ranges for a given hangul syllable type.

Aliases are resolved by this function.

Arguments

  • hangul_syllable_type is any type 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 hangul syllable type is not known.

Examples

iex> Unicode.HangulSyllableType.fetch(:lv) |> elem(0)
:ok

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

get(hangul_syllable_type)

Returns the Unicode codepoint ranges for a given hangul syllable type.

Aliases are resolved by this function.

Arguments

  • hangul_syllable_type is any type name or alias, as an atom or string.

Returns

  • A list of codepoint ranges as 2-tuples.

  • nil if the hangul syllable type is not known.

Examples

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

hangul_syllable_type(string)

Returns the hangul syllable type 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 type atom is returned. Non-Hangul codepoints return :na.

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

Examples

iex> Unicode.HangulSyllableType.hangul_syllable_type(0xAC00)
:lv

iex> Unicode.HangulSyllableType.hangul_syllable_type(?A)
:na

hangul_syllable_types()

Returns the map of Unicode hangul syllable types.

Returns

  • A map where the hangul syllable type is the key and a list of codepoint ranges as 2-tuples is the value.

Examples

iex> :lv in Map.keys(Unicode.HangulSyllableType.hangul_syllable_types())
true

known_hangul_syllable_types()

Returns a list of known Unicode hangul syllable type names.

Returns

  • A list of atom hangul syllable type names.

Examples

iex> :lvt in Unicode.HangulSyllableType.known_hangul_syllable_types()
true