From 972465a3b05442ab9826f4b2baf27d61fc31bce2 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Sun, 2 Jun 2013 15:25:51 +0300 Subject: [PATCH] doc: improve punycode.js documentation --- doc/api/punycode.markdown | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/doc/api/punycode.markdown b/doc/api/punycode.markdown index f8f6a3d2f3e..2de93213be7 100644 --- a/doc/api/punycode.markdown +++ b/doc/api/punycode.markdown @@ -8,8 +8,7 @@ use npm to install the `punycode` module first.) ## punycode.decode(string) -Converts a Punycode string of ASCII code points to a string of Unicode code -points. +Converts a Punycode string of ASCII-only symbols to a string of Unicode symbols. // decode domain name parts punycode.decode('maana-pta'); // 'mañana' @@ -17,8 +16,7 @@ points. ## punycode.encode(string) -Converts a string of Unicode code points to a Punycode string of ASCII code -points. +Converts a string of Unicode symbols to a Punycode string of ASCII-only symbols. // encode domain name parts 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) -Creates an array containing the decimal code points of each Unicode character -in the string. While [JavaScript uses UCS-2 +Creates an array containing the numeric code point values of each Unicode +symbol in the string. While [JavaScript uses UCS-2 internally](http://mathiasbynens.be/notes/javascript-encoding), this function will convert a pair of surrogate halves (each of which UCS-2 exposes as 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: punycode.ucs2.decode('\uD834\uDF06'); // [0x1D306] ### 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.version