idna API reference
Internationalized domain names: convert a Unicode domain to its ASCII-compatible (xn--) form and back, over a Punycode (RFC 3492) core. So münchen.de goes on the wire as xn--mnchen-3ya.de (DNS, SMTP envelopes, URL hosts are ASCII-only). Pure Jennifer over strings, convert, and encoding - no networking, TinyGo-clean. This is the Punycode transformation plus lowercasing, not full IDNA2008 (which layers nameprep / mapping tables on top); it covers the common cases. It needs convert.toCodepoint / convert.fromCodepoint for the bootstring arithmetic on rune values.
Import with import "idna.j" as idna;. See the idna guide for prose and examples.
Functions
idna.isAscii(domain as string)
Report whether a domain is already all-ASCII (needs no conversion).
Parameters
domain{string}- the domain name to test
Returns {bool} - true when every character is ASCII
idna.toAscii(domain as string)
Convert a domain to its ASCII-compatible form, label by label.
Parameters
domain{string}- the (possibly Unicode) domain name
Returns {string} - the ASCII-compatible domain (Unicode labels get an xn-- prefix)
idna.toUnicode(domain as string)
Convert an ASCII-compatible domain back to Unicode, label by label.
Parameters
domain{string}- the ASCII-compatible domain name
Returns {string} - the Unicode domain (xn-- labels get Punycode-decoded)