From d69e66a5df8178f99aaf046210d82f5e5442ad73 Mon Sep 17 00:00:00 2001 From: Stephane Schittly Date: Tue, 6 Mar 2012 11:44:56 +0000 Subject: [PATCH 1/3] http://code.google.com/p/as3corelib/issues/detail?id=132 --- src/com/adobe/serialization/json/JSONEncoder.as | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/com/adobe/serialization/json/JSONEncoder.as b/src/com/adobe/serialization/json/JSONEncoder.as index db69494..e9eac91 100644 --- a/src/com/adobe/serialization/json/JSONEncoder.as +++ b/src/com/adobe/serialization/json/JSONEncoder.as @@ -164,21 +164,20 @@ package com.adobe.serialization.json default: // everything else // check for a control character and escape as unicode - if ( ch < ' ' ) - { + if ( ch < ' ' || ch > '}' ) { // get the hex digit(s) of the character (either 1 or 2 digits) var hexCode:String = ch.charCodeAt( 0 ).toString( 16 ); // ensure that there are 4 digits by adjusting // the # of zeros accordingly. - var zeroPad:String = hexCode.length == 2 ? "00" : "000"; - + while( hexCode.length < 4 ) + { + hexCode = "0"+hexCode; + } // create the unicode escape sequence with 4 hex digits - s += "\\u" + zeroPad + hexCode; - } - else - { - + s += "\\u" + hexCode; + } else { + // no need to do any special encoding, just pass-through s += ch; From 2aea80036dc1ebbc22094a455350dbc0a17ebabd Mon Sep 17 00:00:00 2001 From: Stephane Schittly Date: Tue, 6 Mar 2012 11:57:24 +0000 Subject: [PATCH 2/3] Update src/com/adobe/serialization/json/JSONEncoder.as --- src/com/adobe/serialization/json/JSONEncoder.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/adobe/serialization/json/JSONEncoder.as b/src/com/adobe/serialization/json/JSONEncoder.as index e9eac91..439bcfb 100644 --- a/src/com/adobe/serialization/json/JSONEncoder.as +++ b/src/com/adobe/serialization/json/JSONEncoder.as @@ -175,7 +175,7 @@ package com.adobe.serialization.json hexCode = "0"+hexCode; } // create the unicode escape sequence with 4 hex digits - s += "\\u" + hexCode; + s += "\u" + hexCode; } else { // no need to do any special encoding, just pass-through From 2ad50c62474fa2300fac45b2adf12d783f96625d Mon Sep 17 00:00:00 2001 From: Stephane Schittly Date: Tue, 6 Mar 2012 12:35:01 +0000 Subject: [PATCH 3/3] Update src/com/adobe/serialization/json/JSONEncoder.as --- src/com/adobe/serialization/json/JSONEncoder.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/adobe/serialization/json/JSONEncoder.as b/src/com/adobe/serialization/json/JSONEncoder.as index 439bcfb..e9eac91 100644 --- a/src/com/adobe/serialization/json/JSONEncoder.as +++ b/src/com/adobe/serialization/json/JSONEncoder.as @@ -175,7 +175,7 @@ package com.adobe.serialization.json hexCode = "0"+hexCode; } // create the unicode escape sequence with 4 hex digits - s += "\u" + hexCode; + s += "\\u" + hexCode; } else { // no need to do any special encoding, just pass-through