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

Unicode identifiers and pattern syntax (UAX #31).

An identifier is a start character followed by any number of continue characters, as in most
programming languages, but with every script: "café", "δ", and "変数" are identifiers.

The `:default` profile uses the ID_Start and ID_Continue properties. The `:nfkc` profile uses
XID_Start and XID_Continue, which stay identifiers after NFKC normalization; use it when you
normalize identifiers, as Elixir, Rust, and Python do.

# `profile`

```elixir
@type profile() :: :default | :nfkc
```

An identifier profile.

# `continue?`

```elixir
@spec continue?(non_neg_integer(), profile()) :: boolean()
```

Return `true` if `codepoint` can continue an identifier in `profile`: ID_Continue or
XID_Continue.

## Examples

    iex> Mojibake.Identifier.continue?(?_)
    true

    iex> Mojibake.Identifier.continue?(?-)
    false

# `pattern_syntax?`

```elixir
@spec pattern_syntax?(non_neg_integer()) :: boolean()
```

Return `true` if `codepoint` is reserved for syntax in patterns and programming languages
(Pattern_Syntax), such as `+` or `→`.

## Examples

    iex> Mojibake.Identifier.pattern_syntax?(?+)
    true

# `pattern_white_space?`

```elixir
@spec pattern_white_space?(non_neg_integer()) :: boolean()
```

Return `true` if `codepoint` is white space in patterns (Pattern_White_Space).

## Examples

    iex> Mojibake.Identifier.pattern_white_space?(?\t)
    true

# `start?`

```elixir
@spec start?(non_neg_integer(), profile()) :: boolean()
```

Return `true` if `codepoint` can start an identifier in `profile`: ID_Start or XID_Start.

## Examples

    iex> Mojibake.Identifier.start?(?α)
    true

    iex> Mojibake.Identifier.start?(?_)
    false

# `valid?`

```elixir
@spec valid?(String.t(), profile()) :: boolean()
```

Return `true` if `string` is an identifier in `profile`. The empty string and ill-formed UTF-8
are not identifiers.

## Examples

    iex> Mojibake.Identifier.valid?("café_2")
    true

    iex> Mojibake.Identifier.valid?("2fast")
    false

    iex> Mojibake.Identifier.valid?("a-b")
    false

---

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