Hi,
I'm having a problem getting UTF-8 characters to render and was wondering if anyone has any ideas. Data has been verified as coming back from the backend in a valid UTF-8 format.
I'm using a interceptor servlet that sets the character encoding and content type on the HttpServletResponse as follows:
The body of the response is a String, which I have checked evaluates fine using UTF-8 via debugging using the following command:
I output from the interceptor servlet using the following command:
And I have ensured the server is running using utf8 as the file encoding by adding the following argument to the server startup (both the Jetty development mode server, and the actual Jboss server we use for regular deployments):
Finally, I have added the following lines to the jsp:
The stack trace I get in the developer console is as follows:
I have tried manually evaluating the JSON string (with UTF-8 characters in) using JSOHelper and it works fine.
The screen renders fine if it only uses regular latin characters, but as soon as I try to display a record with non-latin characters, no data is displayed at all (only empty widgets).
I'm using SmartGWT v2.2, IE7.
If anyone can suggest any mistakes I have made with the current approach, or has any information about additional changes I need to make to run SmartGWT with UTF-8 (either config or code), it would be much appreciated.
Thanks.
Mike
I'm having a problem getting UTF-8 characters to render and was wondering if anyone has any ideas. Data has been verified as coming back from the backend in a valid UTF-8 format.
I'm using a interceptor servlet that sets the character encoding and content type on the HttpServletResponse as follows:
Code:
resp.setCharacterEncoding("UTF-8"); resp.setContentType("application/json; charset=utf-8");
Code:
new String(body.getBytes("utf-8"));
Code:
PrintWriter out = resp.getWriter(); out.write(body); out.flush(); out.close();
Code:
-Dfile.encoding=utf8
Code:
<?xml version="1.0" encoding="UTF-8"?> <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> ... ... <head> ... <meta http-equiv="content-type" content="text/html; charset=utf-8" /> ... </head> ...
Code:
com.smartgwt.client.core.JsObject$SGWT_WARN: 09:02:50.875:XRP8:WARN:RestDataSource:appPersonRestDS:Error evaluating JSON: [object Error], JSON text: {"response": { "status": 0, "startRow": 0, "endRow": 1, "totalRows": 1, "data": [{...some data including UTF-8 characters... at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1669) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) at java.lang.Thread.run(Unknown Source)
The screen renders fine if it only uses regular latin characters, but as soon as I try to display a record with non-latin characters, no data is displayed at all (only empty widgets).
I'm using SmartGWT v2.2, IE7.
If anyone can suggest any mistakes I have made with the current approach, or has any information about additional changes I need to make to run SmartGWT with UTF-8 (either config or code), it would be much appreciated.
Thanks.
Mike
Comment