Revert "punycode: Update to v1.0.0"
authorkoichik <koichik@improvement.jp>
Tue, 5 Jun 2012 13:10:37 +0000 (22:10 +0900)
committerkoichik <koichik@improvement.jp>
Tue, 5 Jun 2012 13:10:37 +0000 (22:10 +0900)
This reverts commit 483edbdf1aef40c208f6c96efbbcc3c34122e5f2.
Fixes #3359.

lib/punycode.js

index c3791e3..315f1e4 100644 (file)
@@ -1,4 +1,9 @@
-/*! http://mths.be/punycode by @mathias */
+/*!
+ * Punycode.js <http://mths.be/punycode>
+ * Copyright 2011 Mathias Bynens <http://mathiasbynens.be/>
+ * Available under MIT license <http://mths.be/mit>
+ */
+
 ;(function(root) {
 
        /**
@@ -29,7 +34,7 @@
        delimiter = '-', // '\x2D'
 
        /** Regular expressions */
-       regexNonASCII = /[^ -~]/, // unprintable ASCII chars + non-ASCII chars
+       regexNonASCII = /[^ -~]/, // matches unprintable ASCII chars + non-ASCII chars
        regexPunycode = /^xn--/,
 
        /** Error messages */
        }
 
        /**
-        * 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
+        * Creates an array containing the decimal code points of each character in
+        * the string.
+        * @see `punycode.utf16.encode`
+        * @see <http://tools.ietf.org/html/rfc2781>
+        * @memberOf punycode.utf16
         * @name decode
-        * @param {String} string The Unicode input string (UCS-2).
-        * @returns {Array} The new array of code points.
+        * @param {String} string The Unicode input string.
+        * @returns {Array} The new array.
         */
        function utf16decode(string) {
                var output = [],
         * @memberOf punycode.utf16
         * @name encode
         * @param {Array} codePoints The array of decimal code points.
-        * @returns {String} The new Unicode string (UCS-2).
+        * @returns {String} The new string.
         */
        function utf16encode(array) {
                return map(array, function(value) {
                                }
 
                                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;
                                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;
                                                }
                 * @memberOf punycode
                 * @type String
                 */
-               'version': '1.0.0',
+               'version': '0.2.1',
                /**
                 * An object of methods to convert from JavaScript's internal character
-                * representation (UCS-2) to decimal Unicode code points, and back.
-                * @see <http://mathiasbynens.be/notes/javascript-encoding>
+                * representation to Unicode and back.
                 * @memberOf punycode
                 * @type Object
                 */