# `Mojibake.Hangul`
[🔗](https://github.com/zaerl/mojibake/blob/main/src/elixir/lib/mojibake/hangul.ex#L5)

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.

# `compose`

```elixir
@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

# `decompose`

```elixir
@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

# `jamo?`

```elixir
@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

# `leading_jamo?`

```elixir
@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.

# `syllable?`

```elixir
@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

# `syllable_name`

```elixir
@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"

# `trailing_jamo?`

```elixir
@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.

# `vowel_jamo?`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
