summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Bynens <mathias@qiwi.be>2012-02-24 16:05:10 +0100
committerisaacs <i@izs.me>2012-02-27 14:00:18 -0800
commitcacd651ec6944c7b6596d1c199ab9a37ba9abf7c (patch)
tree54413657ce5abc491784c268eb2e7d2cb643a4ec
parent50cfeef65e60690b6d318a294981aaed4bc98dcc (diff)
downloadandroid-node-v8-cacd651ec6944c7b6596d1c199ab9a37ba9abf7c.tar.gz
android-node-v8-cacd651ec6944c7b6596d1c199ab9a37ba9abf7c.tar.bz2
android-node-v8-cacd651ec6944c7b6596d1c199ab9a37ba9abf7c.zip
punycode: Update to v1.0.0
-rw-r--r--lib/punycode.js32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/punycode.js b/lib/punycode.js
index 286136c8c5..887c968b3a 100644
--- a/lib/punycode.js
+++ b/lib/punycode.js
@@ -1,9 +1,4 @@
-/*!
- * Punycode.js <http://mths.be/punycode>
- * Copyright 2011 Mathias Bynens <http://mathiasbynens.be/>
- * Available under MIT license <http://mths.be/mit>
- */
-
+/*! http://mths.be/punycode by @mathias */
;(function(root) {
/**
@@ -34,7 +29,7 @@
delimiter = '-', // '\x2D'
/** Regular expressions */
- regexNonASCII = /[^ -~]/, // matches unprintable ASCII chars + non-ASCII chars
+ regexNonASCII = /[^ -~]/, // unprintable ASCII chars + non-ASCII chars
regexPunycode = /^xn--/,
/** Error messages */
@@ -97,13 +92,17 @@
}
/**
- * Creates an array containing the decimal code points of each character in
- * the string.
+ * Creates an array containing the decimal code points of each Unicode
+ * character in the string. While JavaScript uses UCS-2 internally,
+ * 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.
* @see `punycode.ucs2.encode`
+ * @see <http://mathiasbynens.be/notes/javascript-encoding>
* @memberOf punycode.ucs2
* @name decode
- * @param {String} string The Unicode input string.
- * @returns {Array} The new array.
+ * @param {String} string The Unicode input string (UCS-2).
+ * @returns {Array} The new array of code points.
*/
function ucs2decode(string) {
var output = [],
@@ -131,7 +130,7 @@
* @memberOf punycode.ucs2
* @name encode
* @param {Array} codePoints The array of decimal code points.
- * @returns {String} The new string.
+ * @returns {String} The new Unicode string (UCS-2).
*/
function ucs2encode(array) {
return map(array, function(value) {
@@ -281,7 +280,7 @@
}
i += digit * w;
- t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
+ t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
if (digit < t) {
break;
@@ -404,7 +403,7 @@
if (currentValue == n) {
// Represent delta as a generalized variable-length integer
for (q = delta, k = base; /* no condition */; k += base) {
- t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
+ t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
if (q < t) {
break;
}
@@ -473,10 +472,11 @@
* @memberOf punycode
* @type String
*/
- 'version': '0.3.0',
+ 'version': '1.0.0',
/**
* An object of methods to convert from JavaScript's internal character
- * representation (UCS-2) to Unicode and back.
+ * representation (UCS-2) to decimal Unicode code points, and back.
+ * @see <http://mathiasbynens.be/notes/javascript-encoding>
* @memberOf punycode
* @type Object
*/