users@glassfish.java.net

Re: Encoding problem with google geocoding service in Glassfish v3 JavaEE 6 App

From: <glassfish_at_javadesktop.org>
Date: Sun, 25 Jul 2010 09:29:21 PDT

Okay i found the solution...
That was my code:

[i]...
URLConnection connection = url.openConnection();
StringBuilder builder = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));

while ((line = reader.readLine()) != null) { builder.append(line);}

String builderString = builder.toString();
...[/i]

Google returned an utf8-string but InputputStreamReader uses the Systems Default Charset which is for example cp1252 for windows.... So the easy Solution is to use:

[i]InputStreamReader(connection.getInputStream(), "UTF-8");[/i]

Damn... thats all!

Cheers, Michael
[Message sent by forum member 'michael7186']

http://forums.java.net/jive/thread.jspa?messageID=478520