Sovite.IDNA.Punycode (sovite v0.6.0)

Copy Markdown View Source

Punycode (RFC 3492): encodes a string of Unicode code points as ASCII letters, digits, and hyphens, for the A-labels of internationalized domain names (xn-- followed by the encoding).

iex> Sovite.IDNA.Punycode.encode("bücher")
{:ok, "bcher-kva"}
iex> Sovite.IDNA.Punycode.decode("bcher-kva")
{:ok, "bücher"}

Both directions work on whole labels and never raise: invalid input returns :error. Case is kept as given; the IDNA rules decide what is valid.

Summary

Functions

Decodes an encoded label into a UTF-8 string (RFC 3492 §6.2).

Encodes a UTF-8 string (RFC 3492 §6.3).

Functions

decode(input)

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

Decodes an encoded label into a UTF-8 string (RFC 3492 §6.2).

encode(string)

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

Encodes a UTF-8 string (RFC 3492 §6.3).