Messed up character encoding with Android + GAE Cloud Endpoints

懵懂的女人 提交于 2019-11-29 07:17:42

SOLVED IT!!!!

I think that this is Google's bug evenly as mine. I assumed that response will be encoded in UTF-8, so I just used:

URL url = new URL(PLACE_AC_API + encodedInput + PLACE_AC_API_OPTIONS);
connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));

With explicitly adding charset argument everything worked out:

BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charset.forName("UTF-8")));

But Google definitely need to see why this behaves differently in local and deployed.

All the best to everyone, thanks for interesting and effort!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!