Is there a way to use UTF-8 with app engine?

前端 未结 4 483
忘掉有多难
忘掉有多难 2020-12-10 03:06

I\'m looking for some explanation on how the app engine deals with character encodings. I\'m working on a client-server application where the server is on app engine.

<
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 03:35

    I see two things you should do.

    1) set system-properties (if you are using it) to utf8 in your appengine-web.xml

    
        
        
        
    
    

    OK that above is what I have but the docs suggest this below:

    
        
    
    

    https://developers.google.com/appengine/docs/java/config/appconfig

    2) specify the encoding when you set the content type or it will revert to the default

    The content type may include the type of character encoding used, for example, text/html; charset=ISO-8859-4.

    I'd try

    resp.setContentType("application/json; charset=UTF-8");
    

    You could also try a writer which lets you set the content type to it directly.

    http://docs.oracle.com/javaee/1.3/api/javax/servlet/ServletResponse.html#getWriter%28%29
    http://docs.oracle.com/javaee/1.3/api/javax/servlet/ServletResponse.html#setContentType(java.lang.String)

    For what it's worth, I need utf8 for Japanese content and I have no trouble. I'm not using a filter or setContentType anyway. I am using gwt and #1 above and it works.

提交回复
热议问题