Internationalized domain names, as IDNA2008 and UTS 46 define them - what
format: idn-hostname asserts and what format: idn-email asks about the
part after the at sign.
A name is read the way a resolver reads it. First the whole string is
MAPPED: the characters Unicode discards in a domain name are dropped, the
compatibility forms are folded (so a fullwidth digit becomes an ASCII one)
and everything is lower-cased. Then it is split on the four characters that
separate labels - . and its ideographic, fullwidth and halfwidth twins.
Each label is then either an A-label, xn-- followed by Punycode, which is
decoded and must re-encode to exactly what arrived, or a U-label, whose
every code point must be PVALID by the derived property of RFC 5892 - and
the handful that are only CONTEXTUALLY valid must satisfy their rule: a
MIDDLE DOT between two ls, a Greek KERAIA before a Greek letter, a
KATAKANA MIDDLE DOT in a label that has Japanese in it, a ZERO WIDTH JOINER
after a virama, and Arabic-Indic digits that do not mix with their extended
cousins. Finally, a name with any right-to-left label answers to the Bidi
rule of RFC 5893, which is what makes 0a.<hebrew> invalid while
<arabic><extended-indic-digit> stays valid.
Two of the tables Unicode publishes have no Java API - the derived property
NFKC_CaseFold and Joining_Type - so the first is computed as
NFC(lower-case(NFKC(x))) and the second from the script and category of
the character, with the right-joining letters of the Arabic block written
out. Both agree with the published data on everything a domain name can
hold; neither is a substitute for the tables themselves.
Internationalized domain names, as IDNA2008 and UTS 46 define them - what `format: idn-hostname` asserts and what `format: idn-email` asks about the part after the at sign. A name is read the way a resolver reads it. First the whole string is MAPPED: the characters Unicode discards in a domain name are dropped, the compatibility forms are folded (so a fullwidth digit becomes an ASCII one) and everything is lower-cased. Then it is split on the four characters that separate labels - `.` and its ideographic, fullwidth and halfwidth twins. Each label is then either an A-label, `xn--` followed by Punycode, which is decoded and must re-encode to exactly what arrived, or a U-label, whose every code point must be PVALID by the derived property of RFC 5892 - and the handful that are only CONTEXTUALLY valid must satisfy their rule: a MIDDLE DOT between two `l`s, a Greek KERAIA before a Greek letter, a KATAKANA MIDDLE DOT in a label that has Japanese in it, a ZERO WIDTH JOINER after a virama, and Arabic-Indic digits that do not mix with their extended cousins. Finally, a name with any right-to-left label answers to the Bidi rule of RFC 5893, which is what makes `0a.<hebrew>` invalid while `<arabic><extended-indic-digit>` stays valid. Two of the tables Unicode publishes have no Java API - the derived property NFKC_CaseFold and Joining_Type - so the first is computed as `NFC(lower-case(NFKC(x)))` and the second from the script and category of the character, with the right-joining letters of the Arabic block written out. Both agree with the published data on everything a domain name can hold; neither is a substitute for the tables themselves.
(code-points s)The code points of s as a vector, so a character outside the basic plane
counts once and not twice.
The code points of `s` as a vector, so a character outside the basic plane counts once and not twice.
(decode s)The string a Punycode body encodes, or nil when it is not Punycode.
The string a Punycode body encodes, or nil when it is not Punycode.
(encode s)s as the body of an A-label - Punycode, without the xn-- prefix.
`s` as the body of an A-label - Punycode, without the `xn--` prefix.
(hostname? s)Whether s is an internationalized host name.
Whether `s` is an internationalized host name.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |