|
@ -8,8 +8,7 @@ use npm to install the `punycode` module first.) |
|
|
|
|
|
|
|
|
## punycode.decode(string) |
|
|
## punycode.decode(string) |
|
|
|
|
|
|
|
|
Converts a Punycode string of ASCII code points to a string of Unicode code |
|
|
Converts a Punycode string of ASCII-only symbols to a string of Unicode symbols. |
|
|
points. |
|
|
|
|
|
|
|
|
|
|
|
// decode domain name parts |
|
|
// decode domain name parts |
|
|
punycode.decode('maana-pta'); // 'mañana' |
|
|
punycode.decode('maana-pta'); // 'mañana' |
|
@ -17,8 +16,7 @@ points. |
|
|
|
|
|
|
|
|
## punycode.encode(string) |
|
|
## punycode.encode(string) |
|
|
|
|
|
|
|
|
Converts a string of Unicode code points to a Punycode string of ASCII code |
|
|
Converts a string of Unicode symbols to a Punycode string of ASCII-only symbols. |
|
|
points. |
|
|
|
|
|
|
|
|
|
|
|
// encode domain name parts |
|
|
// encode domain name parts |
|
|
punycode.encode('mañana'); // 'maana-pta' |
|
|
punycode.encode('mañana'); // 'maana-pta' |
|
@ -48,21 +46,21 @@ you call it with a domain that's already in ASCII. |
|
|
|
|
|
|
|
|
### punycode.ucs2.decode(string) |
|
|
### punycode.ucs2.decode(string) |
|
|
|
|
|
|
|
|
Creates an array containing the decimal code points of each Unicode character |
|
|
Creates an array containing the numeric code point values of each Unicode |
|
|
in the string. While [JavaScript uses UCS-2 |
|
|
symbol in the string. While [JavaScript uses UCS-2 |
|
|
internally](http://mathiasbynens.be/notes/javascript-encoding), this function |
|
|
internally](http://mathiasbynens.be/notes/javascript-encoding), this function |
|
|
will convert a pair of surrogate halves (each of which UCS-2 exposes as |
|
|
will convert a pair of surrogate halves (each of which UCS-2 exposes as |
|
|
separate characters) into a single code point, matching UTF-16. |
|
|
separate characters) into a single code point, matching UTF-16. |
|
|
|
|
|
|
|
|
punycode.ucs2.decode('abc'); // [97, 98, 99] |
|
|
punycode.ucs2.decode('abc'); // [0x61, 0x62, 0x63] |
|
|
// surrogate pair for U+1D306 tetragram for centre: |
|
|
// surrogate pair for U+1D306 tetragram for centre: |
|
|
punycode.ucs2.decode('\uD834\uDF06'); // [0x1D306] |
|
|
punycode.ucs2.decode('\uD834\uDF06'); // [0x1D306] |
|
|
|
|
|
|
|
|
### punycode.ucs2.encode(codePoints) |
|
|
### punycode.ucs2.encode(codePoints) |
|
|
|
|
|
|
|
|
Creates a string based on an array of decimal code points. |
|
|
Creates a string based on an array of numeric code point values. |
|
|
|
|
|
|
|
|
punycode.ucs2.encode([97, 98, 99]); // 'abc' |
|
|
punycode.ucs2.encode([0x61, 0x62, 0x63]); // 'abc' |
|
|
punycode.ucs2.encode([0x1D306]); // '\uD834\uDF06' |
|
|
punycode.ucs2.encode([0x1D306]); // '\uD834\uDF06' |
|
|
|
|
|
|
|
|
## punycode.version |
|
|
## punycode.version |
|
|