Skip to content

Commit

Permalink
1. Added escaping of slashes and unescaping of escaped slashes. I mad…
Browse files Browse the repository at this point in the history
…e it for compatibility with PHP but it's really part of standard.

2. Trailing latin letters of non-ascii-escaped characters are lowercase now. For example \u043d instead of \u043D. I also made it for compatibility with PHP but this time I don't know if the PHP version is right.
  • Loading branch information
programmador committed Sep 8, 2011
1 parent 66eaf8d commit efa4467
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hxjson2/JSONEncoder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class JSONEncoder {
}
#end
switch ( ch ) {
case '/': // solidus
s += "\\/";
case '"': // quotation mark
s += "\\\"";
case '\\': // reverse solidus
Expand Down Expand Up @@ -178,7 +180,7 @@ class JSONEncoder {
}
//var zeroPad:String = hexCode.length == 2 ? "00" : "000";
// create the unicode escape sequence with 4 hex digits
s += "\\u" + zeroPad + hexCode;
s += "\\u" + zeroPad + hexCode.toLowerCase();
} else {
// no need to do any special encoding, just pass-through
s += ch;
Expand Down
2 changes: 2 additions & 0 deletions hxjson2/JSONTokenizer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ class JSONTokenizer {
string += '"';
case '/': // solidus
string += "/";
case '\\/': // escaped solidus
string += "/";
case '\\': // reverse solidus
string += '\\';
case 'n': // newline
Expand Down

0 comments on commit efa4467

Please sign in to comment.