Unicode.IDNA.Context (Unicode IDNA v0.1.0)

View Source

RFC 5892 Appendix A CONTEXTJ rules for the join-control characters Zero Width Non-Joiner (U+200C) and Zero Width Joiner (U+200D).

These rules govern when a join control may appear in a label based on the surrounding code points' Joining_Type and Canonical_Combining_Class properties.

Summary

Functions

Validates a label against the CONTEXTJ rules for ZWJ and ZWNJ.

Functions

validate(label)

@spec validate(String.t()) :: :ok | {:error, :context}

Validates a label against the CONTEXTJ rules for ZWJ and ZWNJ.

Arguments

  • label is a String.t/0 representing one already-mapped domain label.

Returns

  • :ok if every join control in the label is in a permitted context (or if the label contains no join controls).

  • {:error, :context} otherwise.

Examples

iex> Unicode.IDNA.Context.validate("hello")
:ok

iex> Unicode.IDNA.Context.validate("hello\u200Cworld")
{:error, :context}