// Using the punycode.js library
const punycode = require("punycode/");
const domain = "mañana.com";
const ascii = punycode.toASCII(domain);
const unicode = punycode.toUnicode(ascii);
console.log(`Punycode mapping of ${domain}: ${ascii}`);
console.log(`Unicode mapping of ${ascii}: ${domain}`);
Punycode is a specialized representation of Unicode with a limited character set, specifically designed for domain names. DNS (Domain Name Resolution), while it technically can handle all Unicode characters, favors a limited character set called letter-digit-hyphen (LDH). Punycode seeks to encode arbitray Unicode domain names into this character set.
Punycode is a specific algorithm based off of the more general Bootstring algorithm, which composes strings of smaller sets of basic code points from any larger set.