• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{
2  "type": "module",
3  "source": "doc/api/punycode.md",
4  "modules": [
5    {
6      "textRaw": "Punycode",
7      "name": "punycode",
8      "meta": {
9        "deprecated": [
10          "v7.0.0"
11        ],
12        "changes": []
13      },
14      "introduced_in": "v0.10.0",
15      "stability": 0,
16      "stabilityText": "Deprecated",
17      "desc": "<p><strong>Source Code:</strong> <a href=\"https://github.com/nodejs/node/blob/v14.20.1/lib/punycode.js\">lib/punycode.js</a></p>\n<p><strong>The version of the punycode module bundled in Node.js is being deprecated</strong>.\nIn a future major version of Node.js this module will be removed. Users\ncurrently depending on the <code>punycode</code> module should switch to using the\nuserland-provided <a href=\"https://github.com/bestiejs/punycode.js\">Punycode.js</a> module instead. For punycode-based URL\nencoding, see <a href=\"url.html#url_url_domaintoascii_domain\"><code>url.domainToASCII</code></a> or, more generally, the\n<a href=\"url.html#url_the_whatwg_url_api\">WHATWG URL API</a>.</p>\n<p>The <code>punycode</code> module is a bundled version of the <a href=\"https://github.com/bestiejs/punycode.js\">Punycode.js</a> module. It\ncan be accessed using:</p>\n<pre><code class=\"language-js\">const punycode = require('punycode');\n</code></pre>\n<p><a href=\"https://tools.ietf.org/html/rfc3492\">Punycode</a> 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<code>'example'</code> is <code>'例'</code>. The Internationalized Domain Name, <code>'例.com'</code> (equivalent\nto <code>'example.com'</code>) is represented by Punycode as the ASCII string\n<code>'xn--fsq.com'</code>.</p>\n<p>The <code>punycode</code> module provides a simple implementation of the Punycode standard.</p>\n<p>The <code>punycode</code> 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 <a href=\"https://github.com/bestiejs/punycode.js\">Punycode.js</a> project.</p>",
18      "methods": [
19        {
20          "textRaw": "`punycode.decode(string)`",
21          "type": "method",
22          "name": "decode",
23          "meta": {
24            "added": [
25              "v0.5.1"
26            ],
27            "changes": []
28          },
29          "signatures": [
30            {
31              "params": [
32                {
33                  "textRaw": "`string` {string}",
34                  "name": "string",
35                  "type": "string"
36                }
37              ]
38            }
39          ],
40          "desc": "<p>The <code>punycode.decode()</code> method converts a <a href=\"https://tools.ietf.org/html/rfc3492\">Punycode</a> string of ASCII-only\ncharacters to the equivalent string of Unicode codepoints.</p>\n<pre><code class=\"language-js\">punycode.decode('maana-pta'); // 'mañana'\npunycode.decode('--dqo34k'); // '☃-⌘'\n</code></pre>"
41        },
42        {
43          "textRaw": "`punycode.encode(string)`",
44          "type": "method",
45          "name": "encode",
46          "meta": {
47            "added": [
48              "v0.5.1"
49            ],
50            "changes": []
51          },
52          "signatures": [
53            {
54              "params": [
55                {
56                  "textRaw": "`string` {string}",
57                  "name": "string",
58                  "type": "string"
59                }
60              ]
61            }
62          ],
63          "desc": "<p>The <code>punycode.encode()</code> method converts a string of Unicode codepoints to a\n<a href=\"https://tools.ietf.org/html/rfc3492\">Punycode</a> string of ASCII-only characters.</p>\n<pre><code class=\"language-js\">punycode.encode('mañana'); // 'maana-pta'\npunycode.encode('☃-⌘'); // '--dqo34k'\n</code></pre>"
64        },
65        {
66          "textRaw": "`punycode.toASCII(domain)`",
67          "type": "method",
68          "name": "toASCII",
69          "meta": {
70            "added": [
71              "v0.6.1"
72            ],
73            "changes": []
74          },
75          "signatures": [
76            {
77              "params": [
78                {
79                  "textRaw": "`domain` {string}",
80                  "name": "domain",
81                  "type": "string"
82                }
83              ]
84            }
85          ],
86          "desc": "<p>The <code>punycode.toASCII()</code> method converts a Unicode string representing an\nInternationalized Domain Name to <a href=\"https://tools.ietf.org/html/rfc3492\">Punycode</a>. Only the non-ASCII parts of the\ndomain name will be converted. Calling <code>punycode.toASCII()</code> on a string that\nalready only contains ASCII characters will have no effect.</p>\n<pre><code class=\"language-js\">// 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</code></pre>"
87        },
88        {
89          "textRaw": "`punycode.toUnicode(domain)`",
90          "type": "method",
91          "name": "toUnicode",
92          "meta": {
93            "added": [
94              "v0.6.1"
95            ],
96            "changes": []
97          },
98          "signatures": [
99            {
100              "params": [
101                {
102                  "textRaw": "`domain` {string}",
103                  "name": "domain",
104                  "type": "string"
105                }
106              ]
107            }
108          ],
109          "desc": "<p>The <code>punycode.toUnicode()</code> method converts a string representing a domain name\ncontaining <a href=\"https://tools.ietf.org/html/rfc3492\">Punycode</a> encoded characters into Unicode. Only the <a href=\"https://tools.ietf.org/html/rfc3492\">Punycode</a>\nencoded parts of the domain name are be converted.</p>\n<pre><code class=\"language-js\">// 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</code></pre>"
110        }
111      ],
112      "properties": [
113        {
114          "textRaw": "`punycode.ucs2`",
115          "name": "ucs2",
116          "meta": {
117            "added": [
118              "v0.7.0"
119            ],
120            "changes": []
121          },
122          "methods": [
123            {
124              "textRaw": "`punycode.ucs2.decode(string)`",
125              "type": "method",
126              "name": "decode",
127              "meta": {
128                "added": [
129                  "v0.7.0"
130                ],
131                "changes": []
132              },
133              "signatures": [
134                {
135                  "params": [
136                    {
137                      "textRaw": "`string` {string}",
138                      "name": "string",
139                      "type": "string"
140                    }
141                  ]
142                }
143              ],
144              "desc": "<p>The <code>punycode.ucs2.decode()</code> method returns an array containing the numeric\ncodepoint values of each Unicode symbol in the string.</p>\n<pre><code class=\"language-js\">punycode.ucs2.decode('abc'); // [0x61, 0x62, 0x63]\n// surrogate pair for U+1D306 tetragram for centre:\npunycode.ucs2.decode('\\uD834\\uDF06'); // [0x1D306]\n</code></pre>"
145            },
146            {
147              "textRaw": "`punycode.ucs2.encode(codePoints)`",
148              "type": "method",
149              "name": "encode",
150              "meta": {
151                "added": [
152                  "v0.7.0"
153                ],
154                "changes": []
155              },
156              "signatures": [
157                {
158                  "params": [
159                    {
160                      "textRaw": "`codePoints` {integer[]}",
161                      "name": "codePoints",
162                      "type": "integer[]"
163                    }
164                  ]
165                }
166              ],
167              "desc": "<p>The <code>punycode.ucs2.encode()</code> method returns a string based on an array of\nnumeric code point values.</p>\n<pre><code class=\"language-js\">punycode.ucs2.encode([0x61, 0x62, 0x63]); // 'abc'\npunycode.ucs2.encode([0x1D306]); // '\\uD834\\uDF06'\n</code></pre>"
168            }
169          ]
170        },
171        {
172          "textRaw": "`version` {string}",
173          "type": "string",
174          "name": "version",
175          "meta": {
176            "added": [
177              "v0.6.1"
178            ],
179            "changes": []
180          },
181          "desc": "<p>Returns a string identifying the current <a href=\"https://github.com/bestiejs/punycode.js\">Punycode.js</a> version number.</p>"
182        }
183      ],
184      "type": "module",
185      "displayName": "Punycode"
186    }
187  ]
188}