Punycode.js
Last updated
Was this helpful?
Last updated
Was this helpful?
Punycode.js is a robust Punycode converter that fully complies to and .
This JavaScript library is the result of comparing, optimizing and documenting different open-source implementations of the Punycode algorithm:
(note: )
This project was with Node.js from until (soft-deprecated).
The current version supports recent versions of Node.js only. It provides a CommonJS module and an ES6 module. For the old version that offers the same functionality with broader support, including Rhino, Ringo, Narwhal, and web browsers, see .
Via :
In :
punycode.decode(string)
Converts a Punycode string of ASCII symbols to a string of Unicode symbols.
punycode.encode(string)
Converts a string of Unicode symbols to a Punycode string of ASCII symbols.
punycode.toUnicode(input)
Converts a Punycode string representing a domain name or an email address to Unicode. Only the Punycoded parts of the input will be converted, i.e. it doesn’t matter if you call it on a string that has already been converted to Unicode.
punycode.toASCII(input)
Converts a lowercased Unicode string representing a domain name or an email address to Punycode. Only the non-ASCII parts of the input will be converted, i.e. it doesn’t matter if you call it with a domain that’s already in ASCII.
punycode.ucs2
punycode.ucs2.decode(string)
punycode.ucs2.encode(codePoints)
Creates a string based on an array of numeric code point values.
punycode.version
A string representing the current Punycode.js version number.
Creates an array containing the numeric code point values of each Unicode symbol in the string. While , this function will convert a pair of surrogate halves (each of which UCS-2 exposes as separate characters) into a single code point, matching UTF-16.
Punycode.js is available under the license.