Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
punycode: Update to v1.0.0
  • Loading branch information
mathiasbynens authored and isaacs committed Feb 27, 2012
1 parent 70a393e commit 483edbd
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions 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) {

/**
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -97,14 +92,17 @@
}

/**
* 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
* 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 utf16decode(string) {

This comment has been minimized.

Copy link
@mathiasbynens

mathiasbynens May 29, 2012

Author

How come this method is still called utf16decode and not ucs2decode? This doesn’t match Punycode.js v1.0.0. It also doesn’t match this commit: cacd651.

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis May 29, 2012

Member

You're looking at a commit from the v0.6 branch. cacd651 only exists in the master branch.

This comment has been minimized.

Copy link
@mathiasbynens

mathiasbynens May 29, 2012

Author

Yes, but I’m wondering why the v0.6 branch has Punycode v1.0.0 but with a different API than the real v1.0.0 (as in the master branch). Confusing :)

This comment has been minimized.

Copy link
@mathiasbynens

mathiasbynens May 29, 2012

Author

To clarify, I wonder why Node v0.6 has require('punycode').version == '1.0.0' even though the API it exposes it not that of Punycode.js v1.0.0 at all. /cc @isaacs

This comment has been minimized.

Copy link
@mathiasbynens

mathiasbynens Jun 1, 2012

Author

@isaacs, any idea? Should I file a bug on this?

This comment has been minimized.

Copy link
@koichik

koichik Jun 1, 2012

#2456 (punycode v0.3.0) was landed in master, but not v0.6.

This comment has been minimized.

Copy link
@mathiasbynens

mathiasbynens Jun 1, 2012

Author

@koichik Thanks, I get that, but that doesn’t answer 483edbd#commitcomment-1387233. What’s currently in v0.6 is some sort of Frankenstein version that declares itself as Punycode.js v1.0.0 but has v0.3.0’s API.

This comment has been minimized.

Copy link
@koichik

koichik Jun 1, 2012

@mathiasbynens - utf16/ucs2 stuff was included #2456. Please note that we apply patches not the whole file. So, we should apply #2456 in v0.6.

This comment has been minimized.

Copy link
@mathiasbynens
var output = [],
Expand Down Expand Up @@ -133,7 +131,7 @@
* @memberOf punycode.utf16
* @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 utf16encode(array) {
return map(array, function(value) {
Expand Down Expand Up @@ -283,7 +281,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;
Expand Down Expand Up @@ -406,7 +404,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;
}
Expand Down Expand Up @@ -475,10 +473,11 @@
* @memberOf punycode
* @type String
*/
'version': '0.2.1',
'version': '1.0.0',
/**
* 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

This comment has been minimized.

Copy link
@mathiasbynens

mathiasbynens May 29, 2012

Author

Same here, where the methods are exposed on the punycode object.

utf16 should be ucs2, as per the docs, and as in https://github.com/joyent/node/blob/cacd651ec6944c7b6596d1c199ab9a37ba9abf7c/lib/punycode.js.

If not, punycode.version shouldn’t be '1.0.0'.

* @type Object
*/
Expand Down

0 comments on commit 483edbd

Please sign in to comment.