Permalink
Browse files

Minor bugfix for JSON string encoding.

  • Loading branch information...
skyboy committed Jan 19, 2012
1 parent 042a771 commit 76c20c256ffbaa1feee078f276dd535f93f573ad
Showing with 4 additions and 4 deletions.
  1. +4 −4 skyboy/serialization/JSON.as
@@ -316,7 +316,7 @@ package skyboy.serialization {
while (i < e) {
c = data.charCodeAt(i++);
if (int(c < 0x20) | int(c > 0x7E)) { // ' ' | '~'
- t = int(c > 0xFFFF);
+ t = int(c <= 0xFFFF);
t *= 0xFFFF;
rtn.writeShort(0x5C75); // \u
rtn.writeInt(enc[c & t]);
@@ -341,7 +341,7 @@ package skyboy.serialization {
while (i < e) {
c = data.charCodeAt(i++);
if (int(c < 0x20) | int(c > 0x7E)) { // ' ' | '~'
- t = int(c > 0xFFFF);
+ t = int(c <= 0xFFFF);
t *= 0xFFFF;
rtn.writeShort(0x5C75); // \u
rtn.writeInt(enc[c & t]);
@@ -693,10 +693,10 @@ package skyboy.serialization {
if (l > 1) {
throw new Error("Malformed JSON at: " + i + ", '" + data.substr(i, l) + (e ? "'. " + e : "'."), errorID);
} else {
- throw new Error("Malformed JSON at: " + this.i + ' ' + i + ", " + data.charAt(i) + (e ? ". " + e : '.'), errorID);
+ throw new Error("Malformed JSON at: " + i + ", '" + data.charAt(i) + (e ? "'. " + e : '.'), errorID);
}
} else {
- throw new Error("Malformed JSON at char: " + i + ", " + data.charAt(i) + (e ? ". " + e : '.'), errorID);
+ throw new Error("Malformed JSON at char: " + i + ", '" + data.charAt(i) + (e ? "'. " + e : '.'), errorID);
}
}
}

0 comments on commit 76c20c2

Please sign in to comment.