svn commit: r650086 - /ofbiz/branches/release4.0/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r650086 - /ofbiz/branches/release4.0/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java

jleroux@apache.org
Author: jleroux
Date: Mon Apr 21 03:20:59 2008
New Revision: 650086

URL: http://svn.apache.org/viewvc?rev=650086&view=rev
Log:
Applied fix from trunk for revision: 650083

Modified:
    ofbiz/branches/release4.0/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java

Modified: ofbiz/branches/release4.0/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java?rev=650086&r1=650085&r2=650086&view=diff
==============================================================================
--- ofbiz/branches/release4.0/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java (original)
+++ ofbiz/branches/release4.0/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java Mon Apr 21 03:20:59 2008
@@ -19,6 +19,7 @@
 package org.ofbiz.webapp.event;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import java.util.Enumeration;
 import java.util.Map;
@@ -61,7 +62,12 @@
 
         // set the X-JSON content type
         response.setContentType("application/x-json");
-        response.setContentLength(jsonStr.length());
+        // jsonStr.length is not reliable for unicode characters
+        try {
+            response.setContentLength(jsonStr.getBytes("UTF8").length);
+        } catch (UnsupportedEncodingException e) {
+            throw new EventHandlerException("Problems with Json encoding", e);
+        }
 
         // return the JSON String
         Writer out;