Hangul syllables and jamo (Unicode Section 3.12).
A precomposed Hangul syllable is a leading consonant (L, U+1100 to U+1112), a vowel (V, U+1161 to U+1175), and an optional trailing consonant (T, U+11A8 to U+11C2). Normalization composes and decomposes them automatically; these functions work on single syllables.
Summary
Functions
Compose a syllable from a leading consonant, a vowel, and an optional trailing consonant.
Return nil if a jamo is outside its range.
Decompose a syllable into {leading, vowel, trailing}, with trailing nil when it has
none. Return nil if syllable is not a Hangul syllable.
Return true if codepoint is a conjoining jamo: a leading consonant, a vowel, or a trailing
consonant.
Return true if codepoint is a leading consonant jamo (L) that composes into a syllable,
U+1100 to U+1112.
Return true if codepoint is a precomposed Hangul syllable, U+AC00 to U+D7A3.
The character name of a Hangul syllable, derived as Unicode Section 3.12 describes. It does not
need the character-name tables. Return nil if syllable is not a Hangul syllable.
Return true if codepoint is a trailing consonant jamo (T) that composes into a syllable,
U+11A8 to U+11C2.
Return true if codepoint is a vowel jamo (V) that composes into a syllable, U+1161 to
U+1175.
Functions
@spec compose(non_neg_integer(), non_neg_integer(), non_neg_integer() | nil) :: non_neg_integer() | nil
Compose a syllable from a leading consonant, a vowel, and an optional trailing consonant.
Return nil if a jamo is outside its range.
Examples
iex> Mojibake.Hangul.compose(0x1112, 0x1161, 0x11AB)
0xD55C
iex> Mojibake.Hangul.compose(0x1112, 0x1161)
0xD558
iex> Mojibake.Hangul.compose(?a, 0x1161)
nil
@spec decompose(non_neg_integer()) :: {non_neg_integer(), non_neg_integer(), non_neg_integer() | nil} | nil
Decompose a syllable into {leading, vowel, trailing}, with trailing nil when it has
none. Return nil if syllable is not a Hangul syllable.
Examples
iex> Mojibake.Hangul.decompose(?한)
{0x1112, 0x1161, 0x11AB}
iex> Mojibake.Hangul.decompose(?하)
{0x1112, 0x1161, nil}
iex> Mojibake.Hangul.decompose(?a)
nil
@spec jamo?(non_neg_integer()) :: boolean()
Return true if codepoint is a conjoining jamo: a leading consonant, a vowel, or a trailing
consonant.
Examples
iex> Mojibake.Hangul.jamo?(0x1100)
true
iex> Mojibake.Hangul.jamo?(?한)
false
@spec leading_jamo?(non_neg_integer()) :: boolean()
Return true if codepoint is a leading consonant jamo (L) that composes into a syllable,
U+1100 to U+1112.
@spec syllable?(non_neg_integer()) :: boolean()
Return true if codepoint is a precomposed Hangul syllable, U+AC00 to U+D7A3.
Examples
iex> Mojibake.Hangul.syllable?(?한)
true
@spec syllable_name(non_neg_integer()) :: String.t() | nil
The character name of a Hangul syllable, derived as Unicode Section 3.12 describes. It does not
need the character-name tables. Return nil if syllable is not a Hangul syllable.
Examples
iex> Mojibake.Hangul.syllable_name(?한)
"HANGUL SYLLABLE HAN"
@spec trailing_jamo?(non_neg_integer()) :: boolean()
Return true if codepoint is a trailing consonant jamo (T) that composes into a syllable,
U+11A8 to U+11C2.
@spec vowel_jamo?(non_neg_integer()) :: boolean()
Return true if codepoint is a vowel jamo (V) that composes into a syllable, U+1161 to
U+1175.