~yolanda.robla/ubuntu/trusty/nodejs/add_distribution

« back to all changes in this revision

Viewing changes to doc/api/punycode.html

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!doctype html>
 
2
<html lang="en">
 
3
<head>
 
4
  <meta charset="utf-8">
 
5
  <title>punycode Node.js v0.10.15 Manual &amp; Documentation</title>
 
6
  <link rel="stylesheet" href="assets/style.css">
 
7
  <link rel="stylesheet" href="assets/sh.css">
 
8
  <link rel="canonical" href="http://nodejs.org/api/punycode.html">
 
9
</head>
 
10
<body class="alt apidoc" id="api-section-punycode">
 
11
    <div id="intro" class="interior">
 
12
        <a href="/" title="Go back to the home page">
 
13
            <img id="logo" src="http://nodejs.org/images/logo-light.png" alt="node.js">
 
14
        </a>
 
15
    </div>
 
16
    <div id="content" class="clearfix">
 
17
        <div id="column2" class="interior">
 
18
            <ul>
 
19
                <li><a href="/" class="home">Home</a></li>
 
20
                <li><a href="/download/" class="download">Download</a></li>
 
21
                <li><a href="/about/" class="about">About</a></li>
 
22
                <li><a href="http://npmjs.org/" class="npm">npm Registry</a></li>
 
23
                <li><a href="http://nodejs.org/api/" class="docs current">Docs</a></li>
 
24
                <li><a href="http://blog.nodejs.org" class="blog">Blog</a></li>
 
25
                <li><a href="/community/" class="community">Community</a></li>
 
26
                <li><a href="/logos/" class="logos">Logos</a></li>
 
27
                <li><a href="http://jobs.nodejs.org/" class="jobs">Jobs</a></li>
 
28
            </ul>
 
29
            <p class="twitter"><a href="http://twitter.com/nodejs">@nodejs</a></p>
 
30
        </div>
 
31
 
 
32
        <div id="column1" class="interior">
 
33
          <header>
 
34
            <h1>Node.js v0.10.15 Manual &amp; Documentation</h1>
 
35
            <div id="gtoc">
 
36
              <p>
 
37
                <a href="index.html" name="toc">Index</a> |
 
38
                <a href="all.html">View on single page</a> |
 
39
                <a href="punycode.json">View as JSON</a>
 
40
              </p>
 
41
            </div>
 
42
            <hr>
 
43
          </header>
 
44
 
 
45
          <div id="toc">
 
46
            <h2>Table of Contents</h2>
 
47
            <ul>
 
48
<li><a href="#punycode_punycode">punycode</a><ul>
 
49
<li><a href="#punycode_punycode_decode_string">punycode.decode(string)</a></li>
 
50
<li><a href="#punycode_punycode_encode_string">punycode.encode(string)</a></li>
 
51
<li><a href="#punycode_punycode_tounicode_domain">punycode.toUnicode(domain)</a></li>
 
52
<li><a href="#punycode_punycode_toascii_domain">punycode.toASCII(domain)</a></li>
 
53
<li><a href="#punycode_punycode_ucs2">punycode.ucs2</a><ul>
 
54
<li><a href="#punycode_punycode_ucs2_decode_string">punycode.ucs2.decode(string)</a></li>
 
55
<li><a href="#punycode_punycode_ucs2_encode_codepoints">punycode.ucs2.encode(codePoints)</a></li>
 
56
</ul>
 
57
</li>
 
58
<li><a href="#punycode_punycode_version">punycode.version</a></li>
 
59
</ul>
 
60
</li>
 
61
</ul>
 
62
 
 
63
          </div>
 
64
 
 
65
          <div id="apicontent">
 
66
            <h1>punycode<span><a class="mark" href="#punycode_punycode" id="punycode_punycode">#</a></span></h1>
 
67
<pre class="api_stability_2">Stability: 2 - Unstable</pre><p><a href="http://mths.be/punycode">Punycode.js</a> is bundled with Node.js v0.6.2+. Use
 
68
<code>require(&#39;punycode&#39;)</code> to access it. (To use it with other Node.js versions,
 
69
use npm to install the <code>punycode</code> module first.)
 
70
 
 
71
</p>
 
72
<h2>punycode.decode(string)<span><a class="mark" href="#punycode_punycode_decode_string" id="punycode_punycode_decode_string">#</a></span></h2>
 
73
<p>Converts a Punycode string of ASCII code points to a string of Unicode code
 
74
points.
 
75
 
 
76
</p>
 
77
<pre><code>// decode domain name parts
 
78
punycode.decode(&#39;maana-pta&#39;); // &#39;mañana&#39;
 
79
punycode.decode(&#39;--dqo34k&#39;); // &#39;☃-⌘&#39;</code></pre>
 
80
<h2>punycode.encode(string)<span><a class="mark" href="#punycode_punycode_encode_string" id="punycode_punycode_encode_string">#</a></span></h2>
 
81
<p>Converts a string of Unicode code points to a Punycode string of ASCII code
 
82
points.
 
83
 
 
84
</p>
 
85
<pre><code>// encode domain name parts
 
86
punycode.encode(&#39;mañana&#39;); // &#39;maana-pta&#39;
 
87
punycode.encode(&#39;☃-⌘&#39;); // &#39;--dqo34k&#39;</code></pre>
 
88
<h2>punycode.toUnicode(domain)<span><a class="mark" href="#punycode_punycode_tounicode_domain" id="punycode_punycode_tounicode_domain">#</a></span></h2>
 
89
<p>Converts a Punycode string representing a domain name to Unicode. Only the
 
90
Punycoded parts of the domain name will be converted, i.e. it doesn&#39;t matter if
 
91
you call it on a string that has already been converted to Unicode.
 
92
 
 
93
</p>
 
94
<pre><code>// decode domain names
 
95
punycode.toUnicode(&#39;xn--maana-pta.com&#39;); // &#39;mañana.com&#39;
 
96
punycode.toUnicode(&#39;xn----dqo34k.com&#39;); // &#39;☃-⌘.com&#39;</code></pre>
 
97
<h2>punycode.toASCII(domain)<span><a class="mark" href="#punycode_punycode_toascii_domain" id="punycode_punycode_toascii_domain">#</a></span></h2>
 
98
<p>Converts a Unicode string representing a domain name to Punycode. Only the
 
99
non-ASCII parts of the domain name will be converted, i.e. it doesn&#39;t matter if
 
100
you call it with a domain that&#39;s already in ASCII.
 
101
 
 
102
</p>
 
103
<pre><code>// encode domain names
 
104
punycode.toASCII(&#39;mañana.com&#39;); // &#39;xn--maana-pta.com&#39;
 
105
punycode.toASCII(&#39;☃-⌘.com&#39;); // &#39;xn----dqo34k.com&#39;</code></pre>
 
106
<h2>punycode.ucs2<span><a class="mark" href="#punycode_punycode_ucs2" id="punycode_punycode_ucs2">#</a></span></h2>
 
107
<h3>punycode.ucs2.decode(string)<span><a class="mark" href="#punycode_punycode_ucs2_decode_string" id="punycode_punycode_ucs2_decode_string">#</a></span></h3>
 
108
<p>Creates an array containing the decimal code points of each Unicode character
 
109
in the string. While <a href="http://mathiasbynens.be/notes/javascript-encoding">JavaScript uses UCS-2
 
110
internally</a>, this function
 
111
will convert a pair of surrogate halves (each of which UCS-2 exposes as
 
112
separate characters) into a single code point, matching UTF-16.
 
113
 
 
114
</p>
 
115
<pre><code>punycode.ucs2.decode(&#39;abc&#39;); // [97, 98, 99]
 
116
// surrogate pair for U+1D306 tetragram for centre:
 
117
punycode.ucs2.decode(&#39;\uD834\uDF06&#39;); // [0x1D306]</code></pre>
 
118
<h3>punycode.ucs2.encode(codePoints)<span><a class="mark" href="#punycode_punycode_ucs2_encode_codepoints" id="punycode_punycode_ucs2_encode_codepoints">#</a></span></h3>
 
119
<p>Creates a string based on an array of decimal code points.
 
120
 
 
121
</p>
 
122
<pre><code>punycode.ucs2.encode([97, 98, 99]); // &#39;abc&#39;
 
123
punycode.ucs2.encode([0x1D306]); // &#39;\uD834\uDF06&#39;</code></pre>
 
124
<h2>punycode.version<span><a class="mark" href="#punycode_punycode_version" id="punycode_punycode_version">#</a></span></h2>
 
125
<p>A string representing the current Punycode.js version number.
 
126
</p>
 
127
 
 
128
          </div>
 
129
        </div>
 
130
    </div>
 
131
    <div id="footer">
 
132
        <a href="http://joyent.com" class="joyent-logo">Joyent</a>
 
133
        <ul class="clearfix">
 
134
            <li><a href="/">Node.js</a></li>
 
135
            <li><a href="/download/">Download</a></li>
 
136
            <li><a href="/about/">About</a></li>
 
137
            <li><a href="http://npmjs.org/">npm Registry</a></li>
 
138
            <li><a href="http://nodejs.org/api/">Docs</a></li>
 
139
            <li><a href="http://blog.nodejs.org">Blog</a></li>
 
140
            <li><a href="/community/">Community</a></li>
 
141
            <li><a href="/logos/">Logos</a></li>
 
142
            <li><a href="http://jobs.nodejs.org/">Jobs</a></li>
 
143
            <li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
 
144
        </ul>
 
145
 
 
146
        <p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.10.15/LICENSE">license</a>.</p>
 
147
    </div>
 
148
 
 
149
  <script src="../sh_main.js"></script>
 
150
  <script src="../sh_javascript.min.js"></script>
 
151
  <script>highlight(undefined, undefined, 'pre');</script>
 
152
  <script>
 
153
    window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
 
154
    (function(d, t) {
 
155
      var g = d.createElement(t),
 
156
          s = d.getElementsByTagName(t)[0];
 
157
      g.src = '//www.google-analytics.com/ga.js';
 
158
      s.parentNode.insertBefore(g, s);
 
159
    }(document, 'script'));
 
160
  </script>
 
161
</body>
 
162
</html>
 
163