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

前端 未结 4 482
忘掉有多难
忘掉有多难 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:57

    Found a way to work around it. This is how I did it:

    • Used "application/json; charset=UTF-8" as the content-type. Alternatively, set the response charset to "UTF-8" (either will work fine, no need to do both).

    • Base64-encoded the input strings that aren't ASCII-safe and come as UTF-8. Otherwise they get converted to ISO-8859-1 when they get to the servlet, apparently.

    • Used resp.getWriter() instead of resp.getOutputStream() to print the JSON response.

    After all those conditions were met, I was finally able to output UTF-8 back to the client.

提交回复
热议问题