# `Unicode.Transform.Resolve`
[🔗](https://github.com/elixir-unicode/unicode_transform/blob/v1.1.0/lib/unicode/transform/resolve.ex#L1)

Resolves transform options and IDs to canonical transform identifiers.

This module handles the mapping from user-facing options (`:from`, `:to`,
`:transform`, `:direction`) to the internal transform ID and direction
used by the engine. It also provides conversions between BCP47 (ISO 15924)
script codes and Unicode/CLDR script names.

See the [Transform ID resolution](#module-transform-id-resolution) section
in `Unicode.Transform` for a full description of the resolution process.

# `bcp47_script_to_unicode`

```elixir
@spec bcp47_script_to_unicode(String.t()) :: String.t() | nil
```

Converts a BCP47 (ISO 15924) script code to its Unicode script name.

### Arguments

* `code` — a BCP47 script code string (e.g., `"Latn"`, `"Grek"`).

### Returns

The Unicode script name string if found, or `nil`.

### Examples

    iex> Unicode.Transform.Resolve.bcp47_script_to_unicode("Latn")
    "Latin"

    iex> Unicode.Transform.Resolve.bcp47_script_to_unicode("Grek")
    "Greek"

    iex> Unicode.Transform.Resolve.bcp47_script_to_unicode("Unknown")
    nil

# `resolve_bcp47_transform_id`

```elixir
@spec resolve_bcp47_transform_id(String.t()) :: String.t()
```

Converts a transform ID from BCP47 script codes to CLDR names.

Replaces each segment of the transform ID that is a known BCP47
script code with its CLDR full name.

### Arguments

* `transform_id` — a transform ID string that may contain BCP47 codes.

### Returns

The transform ID with BCP47 codes replaced by CLDR names.

### Examples

    iex> Unicode.Transform.Resolve.resolve_bcp47_transform_id("Grek-Latn")
    "Greek-Latin"

    iex> Unicode.Transform.Resolve.resolve_bcp47_transform_id("Cyrl-Latn")
    "Cyrillic-Latin"

    iex> Unicode.Transform.Resolve.resolve_bcp47_transform_id("Latin-ASCII")
    "Latin-ASCII"

# `resolve_options`

```elixir
@spec resolve_options(keyword()) ::
  {:ok, String.t(), :forward | :reverse} | {:detect, term()} | {:error, term()}
```

Resolves keyword options to a `{transform_id, direction}` tuple.

### Arguments

* `options` — the keyword list of transform options.

### Returns

* `{:ok, transform_id, direction}` when a specific transform is resolved.

* `{:detect, to}` when script detection should be used.

* `{:error, reason}` on invalid or missing options.

# `resolve_to_name`

```elixir
@spec resolve_to_name(atom() | String.t()) :: String.t() | {:error, term()}
```

Resolves the target name from an atom or string.

Used when resolving the target for script detection.

### Arguments

* `to` — the target as an atom or string.

### Returns

The canonical target name string, or `{:error, reason}`.

# `script_name`

```elixir
@spec script_name(atom()) :: String.t() | nil
```

Returns the canonical script name for a script atom.

### Arguments

* `atom` — a script atom (e.g., `:greek`, `:grek`, `:latin`).

### Returns

The canonical script name string if found, or `nil`.

### Examples

    iex> Unicode.Transform.Resolve.script_name(:greek)
    "Greek"

    iex> Unicode.Transform.Resolve.script_name(:grek)
    "Greek"

    iex> Unicode.Transform.Resolve.script_name(:unknown_script)
    nil

# `to_bcp47_transform_id`

```elixir
@spec to_bcp47_transform_id(String.t()) :: String.t()
```

Converts a transform ID from CLDR names to BCP47 script codes.

Replaces each segment of the transform ID that is a known CLDR
script name with its BCP47 code.

### Arguments

* `transform_id` — a transform ID string that may contain CLDR names.

### Returns

The transform ID with CLDR names replaced by BCP47 codes.

### Examples

    iex> Unicode.Transform.Resolve.to_bcp47_transform_id("Greek-Latin")
    "Grek-Latn"

    iex> Unicode.Transform.Resolve.to_bcp47_transform_id("Latin-ASCII")
    "Latn-ASCII"

    iex> Unicode.Transform.Resolve.to_bcp47_transform_id("de-ASCII")
    "de-ASCII"

# `unicode_script_to_bcp47`

```elixir
@spec unicode_script_to_bcp47(String.t()) :: String.t() | nil
```

Converts a Unicode script name to its BCP47 (ISO 15924) code.

### Arguments

* `name` — a Unicode script name string (e.g., `"Latin"`, `"Greek"`).

### Returns

The BCP47 code string if found, or `nil`.

### Examples

    iex> Unicode.Transform.Resolve.unicode_script_to_bcp47("Latin")
    "Latn"

    iex> Unicode.Transform.Resolve.unicode_script_to_bcp47("Greek")
    "Grek"

    iex> Unicode.Transform.Resolve.unicode_script_to_bcp47("Unknown")
    nil

---

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