|
@ -1,9 +1,4 @@ |
|
|
/*! |
|
|
/*! 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) { |
|
|
;(function(root) { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -34,7 +29,7 @@ |
|
|
delimiter = '-', // '\x2D'
|
|
|
delimiter = '-', // '\x2D'
|
|
|
|
|
|
|
|
|
/** Regular expressions */ |
|
|
/** Regular expressions */ |
|
|
regexNonASCII = /[^ -~]/, // matches unprintable ASCII chars + non-ASCII chars
|
|
|
regexNonASCII = /[^ -~]/, // unprintable ASCII chars + non-ASCII chars
|
|
|
regexPunycode = /^xn--/, |
|
|
regexPunycode = /^xn--/, |
|
|
|
|
|
|
|
|
/** Error messages */ |
|
|
/** Error messages */ |
|
@ -97,14 +92,17 @@ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Creates an array containing the decimal code points of each character in |
|
|
* Creates an array containing the decimal code points of each Unicode |
|
|
* the string. |
|
|
* character in the string. While JavaScript uses UCS-2 internally, |
|
|
* @see `punycode.utf16.encode` |
|
|
* this function will convert a pair of surrogate halves (each of which |
|
|
* @see <http://tools.ietf.org/html/rfc2781>
|
|
|
* UCS-2 exposes as separate characters) into a single code point, |
|
|
* @memberOf punycode.utf16 |
|
|
* matching UTF-16. |
|
|
|
|
|
* @see `punycode.ucs2.encode` |
|
|
|
|
|
* @see <http://mathiasbynens.be/notes/javascript-encoding>
|
|
|
|
|
|
* @memberOf punycode.ucs2 |
|
|
* @name decode |
|
|
* @name decode |
|
|
* @param {String} string The Unicode input string. |
|
|
* @param {String} string The Unicode input string (UCS-2). |
|
|
* @returns {Array} The new array. |
|
|
* @returns {Array} The new array of code points. |
|
|
*/ |
|
|
*/ |
|
|
function utf16decode(string) { |
|
|
function utf16decode(string) { |
|
|
var output = [], |
|
|
var output = [], |
|
@ -133,7 +131,7 @@ |
|
|
* @memberOf punycode.utf16 |
|
|
* @memberOf punycode.utf16 |
|
|
* @name encode |
|
|
* @name encode |
|
|
* @param {Array} codePoints The array of decimal code points. |
|
|
* @param {Array} codePoints The array of decimal code points. |
|
|
* @returns {String} The new string. |
|
|
* @returns {String} The new Unicode string (UCS-2). |
|
|
*/ |
|
|
*/ |
|
|
function utf16encode(array) { |
|
|
function utf16encode(array) { |
|
|
return map(array, function(value) { |
|
|
return map(array, function(value) { |
|
@ -283,7 +281,7 @@ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
i += digit * w; |
|
|
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) { |
|
|
if (digit < t) { |
|
|
break; |
|
|
break; |
|
@ -406,7 +404,7 @@ |
|
|
if (currentValue == n) { |
|
|
if (currentValue == n) { |
|
|
// Represent delta as a generalized variable-length integer
|
|
|
// Represent delta as a generalized variable-length integer
|
|
|
for (q = delta, k = base; /* no condition */; k += base) { |
|
|
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) { |
|
|
if (q < t) { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -475,10 +473,11 @@ |
|
|
* @memberOf punycode |
|
|
* @memberOf punycode |
|
|
* @type String |
|
|
* @type String |
|
|
*/ |
|
|
*/ |
|
|
'version': '0.2.1', |
|
|
'version': '1.0.0', |
|
|
/** |
|
|
/** |
|
|
* An object of methods to convert from JavaScript's internal character |
|
|
* An object of methods to convert from JavaScript's internal character |
|
|
* representation to Unicode and back. |
|
|
* representation (UCS-2) to decimal Unicode code points, and back. |
|
|
|
|
|
* @see <http://mathiasbynens.be/notes/javascript-encoding>
|
|
|
* @memberOf punycode |
|
|
* @memberOf punycode |
|
|
* @type Object |
|
|
* @type Object |
|
|
*/ |
|
|
*/ |
|
|