Punycode
Punycode is an encoding that converts Unicode strings (internationalized domain names) into ASCII-compatible strings, with output marked by the xn-- prefix.
Purpose
It lets domain names in non-Latin scripts resolve over the ASCII-only DNS infrastructure while staying compatible with existing systems.
Mechanism
All basic ASCII code points in the input are kept in place; non-ASCII code points are appended at the end via generalized variable-length integer encoding, with a delimiter and insertion positions recovering the order. The output consists entirely of lowercase ASCII letters, digits, and hyphens.
Use cases
- Internationalized domain names (e.g., a Japanese example domain whose labels encode to xn--r8jz45g.xn--zckzah)
- IDN registration and resolution
- Internationalized email addresses (SMTPUTF8 fallback)
- Compatibility layer for DNS software
Examples
- Input
münchenOutputxn--mnchen-3yaEncoding a German city name
Common errors
- Skipping homograph attack checks for IDN names
- Use ICU to detect suspicious mixed scripts before rendering
Related terms
URL Encoding
URL encoding (percent-encoding) converts characters not allowed in URLs into %HH form, so arbitrary data can appear safely in URL components. GLOSSARY
Unicode
Unicode is the international character encoding standard that assigns a unique code point (U+0000 through U+10FFFF) to every character of nearly all the world's writing systems, with a codespace of 1,114,112 code points. GLOSSARY
DNS
DNS resolves domain names to IP addresses, split into recursive and authoritative resolution, forming the foundation of Internet addressing. GLOSSARY