Android + GAE cloud-encoded character encoding

I made a web application using the GAE Cloud endpoints. The application has only a backend part. The application calls the Google Places API and parses JSON responses, creating objects that are returned to the client. Client is an Android application that uses the generated GAE client libraries.

My problem is this: an application running on a local dev server displays the correct lines in UTF-8 format on Android, but the deployed application displays on Android mixed lines. For example: Instead of the Centar Clinic, this shows the Centrar Clinics.

I use the latest Fedeora GNU / Linux, developing in Eclipse Kepler (newest version), GAE - version 1.8.1, Google plugin for Eclipse version 3.2.4 (latest).

I have lost an incredible amount of time trying to solve this. I assume the solution is some configuration line that forces UTF-8. Just mention what I have in my appengine-web.xml below:

 <system-properties> <property name="java.util.logging.config.file" value="WEB-INF/logging.properties" /> <property name="file.encoding" value="UTF-8" /> <property name="DEFAULT_ENCODING" value="UTF-8" /> </system-properties> 

Thanks in advance for every suggestion.

+6
source share
1 answer

WE SOLVE IT !!!!

I think this is a Google bug, just like mine. I assumed that the answer would 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 the explicit addition of the charset argument, everything worked out:

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

But Google definitely needs to understand why this happens differently in the local and the deployed.

All the best for everyone, thanks for your interest and effort!

+4
source

Source: https://habr.com/ru/post/947543/


All Articles