define(function(require) {
-var decode = function(array, string) {
+var decode = function(string, points) {
+ if (typeof points === "undefined")
+ points = [];
+
for (var i = 0, e = string.length; i != e; ++i) {
var unit = string.charCodeAt(i);
var part = unit & 0xfc00;
if (part == 0xdc00)
return null;
else if (part != 0xd800)
- array.push(unit);
+ points.push(unit);
else if (++i == e)
return null;
else {
var next = string.charCodeAt(i);
if ((next & 0xfc00) != 0xdc00)
return null;
- array.push(0x10000 | (unit & 0x03ff) << 10 | next & 0x03ff);
+ points.push(0x10000 | (unit & 0x03ff) << 10 | next & 0x03ff);
}
}
- return array;
+ return points;
};
-var encode = function(array) {
+var encode = function(points) {
var units = [];
- for (var i = 0, e = array.length; i != e; ++i) {
- var point = array[i];
+ for (var i = 0, e = points.length; i != e; ++i) {
+ var point = points[i];
if (point < 0x10000)
units.push(point);
else {