package idna

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module IdnaSource

Internationalized domain name validation, Punycode encoding/decoding, and Unicode NFC normalization.

Validates hostnames and labels per IDNA2008 (RFC 5890/5892). Handles A-labels (xn-- Punycode), U-labels (Unicode), and ASCII labels.

Sourceval is_valid_hostname : string -> bool

Check if a hostname is valid. Splits on dots, validates each label, enforces DNS length limits and domain-level bidirectional text rules.

Sourceval check_label : string -> (unit, string) result

Validate a single label (without dots). Decodes xn-- prefix if present. Checks codepoint validity, hyphen rules, NFC form, initial combining mark, bidirectional text, and CONTEXTJ/CONTEXTO rules.

Sourceval is_valid_hostname_bidi : string list -> bool

Check bidirectional text rules across all labels in a domain. If any label contains right-to-left characters, all labels must satisfy bidirectional text constraints.

Sourceval nfc : int list -> int list

Normalize a codepoint sequence to Unicode NFC (Normalization Form C). Applies canonical decomposition, canonical ordering of combining marks, and canonical composition including Hangul syllables.

Sourceval to_ascii : string -> (string, string) result

Convert a domain name to its ASCII-compatible form (UTS #46 Nontransitional). Maps, normalizes to NFC, splits on dots, validates, and Punycode-encodes non-ASCII labels. Returns the ASCII domain or an error.

Sourceval to_unicode : string -> (string, string) result

Convert a domain name to its Unicode form (UTS #46 Nontransitional). Maps, normalizes to NFC, splits on dots, validates, and Punycode-decodes xn-- labels. Returns the Unicode domain or an error.

Sourcemodule Punycode : sig ... end

Punycode encoding and decoding (RFC 3492).