{ "type": "module", "source": "doc/api/punycode.md", "modules": [ { "textRaw": "Punycode", "name": "punycode", "meta": { "deprecated": [ "v7.0.0" ], "changes": [] }, "introduced_in": "v0.10.0", "stability": 0, "stabilityText": "Deprecated", "desc": "

Source Code: lib/punycode.js

\n

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. For punycode-based URL\nencoding, see url.domainToASCII or, more generally, the\nWHATWG URL API.

\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

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.

", "methods": [ { "textRaw": "`punycode.decode(string)`", "type": "method", "name": "decode", "meta": { "added": [ "v0.5.1" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`string` {string}", "name": "string", "type": "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
" }, { "textRaw": "`punycode.encode(string)`", "type": "method", "name": "encode", "meta": { "added": [ "v0.5.1" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`string` {string}", "name": "string", "type": "string" } ] } ], "desc": "

The punycode.encode() method converts a string of Unicode codepoints to a\nPunycode string of ASCII-only characters.

\n
punycode.encode('mañana'); // 'maana-pta'\npunycode.encode('☃-⌘'); // '--dqo34k'\n
" }, { "textRaw": "`punycode.toASCII(domain)`", "type": "method", "name": "toASCII", "meta": { "added": [ "v0.6.1" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`domain` {string}", "name": "domain", "type": "string" } ] } ], "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
" }, { "textRaw": "`punycode.toUnicode(domain)`", "type": "method", "name": "toUnicode", "meta": { "added": [ "v0.6.1" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`domain` {string}", "name": "domain", "type": "string" } ] } ], "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
" } ], "properties": [ { "textRaw": "`punycode.ucs2`", "name": "ucs2", "meta": { "added": [ "v0.7.0" ], "changes": [] }, "methods": [ { "textRaw": "`punycode.ucs2.decode(string)`", "type": "method", "name": "decode", "meta": { "added": [ "v0.7.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`string` {string}", "name": "string", "type": "string" } ] } ], "desc": "

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
" }, { "textRaw": "`punycode.ucs2.encode(codePoints)`", "type": "method", "name": "encode", "meta": { "added": [ "v0.7.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`codePoints` {integer[]}", "name": "codePoints", "type": "integer[]" } ] } ], "desc": "

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
" } ] }, { "textRaw": "`version` {string}", "type": "string", "name": "version", "meta": { "added": [ "v0.6.1" ], "changes": [] }, "desc": "

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

" } ], "type": "module", "displayName": "Punycode" } ] }