{ "source": "doc/api/punycode.md", "modules": [ { "textRaw": "punycode", "name": "punycode", "stability": 0, "stabilityText": "Deprecated", "desc": "

The version of the punycode module bundled in Node.js is being deprecated.\nIn a future major version of Node.js this module will be removed. Users\ncurrently depending on the punycode module should switch to using the\nuserland-provided [Punycode.js][] module instead.

\n

The punycode module is a bundled version of the [Punycode.js][] module. It\ncan be accessed using:

\n
const punycode = require('punycode');\n
\n

[Punycode][] is a character encoding scheme defined by RFC 3492 that is\nprimarily intended for use in Internationalized Domain Names. Because host\nnames in URLs are limited to ASCII characters only, Domain Names that contain\nnon-ASCII characters must be converted into ASCII using the Punycode scheme.\nFor instance, the Japanese character that translates into the English word,\n'example' is '例'. The Internationalized Domain Name, '例.com' (equivalent\nto 'example.com') is represented by Punycode as the ASCII string\n'xn--fsq.com'.

\n

The punycode module provides a simple implementation of the Punycode standard.

\n

Note: The punycode module is a third-party dependency used by Node.js and\nmade available to developers as a convenience. Fixes or other modifications to\nthe module must be directed to the [Punycode.js][] project.

\n", "methods": [ { "textRaw": "punycode.decode(string)", "type": "method", "name": "decode", "meta": { "added": [ "v0.5.1" ] }, "signatures": [ { "params": [ { "textRaw": "`string` {String} ", "name": "string", "type": "String" } ] }, { "params": [ { "name": "string" } ] } ], "desc": "

The punycode.decode() method converts a [Punycode][] string of ASCII-only\ncharacters to the equivalent string of Unicode codepoints.

\n
punycode.decode('maana-pta'); // 'mañana'\npunycode.decode('--dqo34k'); // '☃-⌘'\n
\n" }, { "textRaw": "punycode.encode(string)", "type": "method", "name": "encode", "meta": { "added": [ "v0.5.1" ] }, "signatures": [ { "params": [ { "textRaw": "`string` {String} ", "name": "string", "type": "String" } ] }, { "params": [ { "name": "string" } ] } ], "desc": "

The punycode.encode() method converts a string of Unicode codepoints to a\n[Punycode][] string of ASCII-only characters.

\n
punycode.encode('mañana'); // 'maana-pta'\npunycode.encode('☃-⌘'); // '--dqo34k'\n
\n" }, { "textRaw": "punycode.toASCII(domain)", "type": "method", "name": "toASCII", "meta": { "added": [ "v0.6.1" ] }, "signatures": [ { "params": [ { "textRaw": "`domain` {String} ", "name": "domain", "type": "String" } ] }, { "params": [ { "name": "domain" } ] } ], "desc": "

The punycode.toASCII() method converts a Unicode string representing an\nInternationalized Domain Name to [Punycode][]. Only the non-ASCII parts of the\ndomain name will be converted. Calling punycode.toASCII() on a string that\nalready only contains ASCII characters will have no effect.

\n
// encode domain names\npunycode.toASCII('mañana.com');  // 'xn--maana-pta.com'\npunycode.toASCII('☃-⌘.com');   // 'xn----dqo34k.com'\npunycode.toASCII('example.com'); // 'example.com'\n
\n" }, { "textRaw": "punycode.toUnicode(domain)", "type": "method", "name": "toUnicode", "meta": { "added": [ "v0.6.1" ] }, "signatures": [ { "params": [ { "textRaw": "`domain` {String} ", "name": "domain", "type": "String" } ] }, { "params": [ { "name": "domain" } ] } ], "desc": "

The punycode.toUnicode() method converts a string representing a domain name\ncontaining [Punycode][] encoded characters into Unicode. Only the [Punycode][]\nencoded parts of the domain name are be converted.

\n
// decode domain names\npunycode.toUnicode('xn--maana-pta.com'); // 'mañana.com'\npunycode.toUnicode('xn----dqo34k.com');  // '☃-⌘.com'\npunycode.toUnicode('example.com');       // 'example.com'\n
\n" } ], "properties": [ { "textRaw": "punycode.ucs2", "name": "ucs2", "meta": { "added": [ "v0.7.0" ] }, "modules": [ { "textRaw": "punycode.ucs2.decode(string)", "name": "punycode.ucs2.decode(string)", "meta": { "added": [ "v0.7.0" ] }, "desc": "\n

The punycode.ucs2.decode() method returns an array containing the numeric\ncodepoint values of each Unicode symbol in the string.

\n
punycode.ucs2.decode('abc'); // [0x61, 0x62, 0x63]\n// surrogate pair for U+1D306 tetragram for centre:\npunycode.ucs2.decode('\\uD834\\uDF06'); // [0x1D306]\n
\n", "type": "module", "displayName": "punycode.ucs2.decode(string)" }, { "textRaw": "punycode.ucs2.encode(codePoints)", "name": "punycode.ucs2.encode(codepoints)", "meta": { "added": [ "v0.7.0" ] }, "desc": "\n

The punycode.ucs2.encode() method returns a string based on an array of\nnumeric code point values.

\n
punycode.ucs2.encode([0x61, 0x62, 0x63]); // 'abc'\npunycode.ucs2.encode([0x1D306]); // '\\uD834\\uDF06'\n
\n", "type": "module", "displayName": "punycode.ucs2.encode(codePoints)" } ] }, { "textRaw": "punycode.version", "name": "version", "meta": { "added": [ "v0.6.1" ] }, "desc": "

Returns a string identifying the current [Punycode.js][] version number.

\n" } ], "type": "module", "displayName": "punycode" } ] }