How to display characters in http get response correctly with the right encoding

Posted by DixieFlatline on Stack Overflow See other posts from Stack Overflow or by DixieFlatline
Published on 2010-05-13T10:10:11Z Indexed on 2010/05/13 10:14 UTC
Read the original article Hit count: 313

Filed under:
|
|

Hello!

Does anyone know how to read c,š,ž characters in http get response properly? When i make my request in browser the browser displays all characters correctly. But in java program with apache jars i don't know how to set the encoding right. I tried with client.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8"); but it's not working.

My code:

    HttpClient client = new DefaultHttpClient();  
    String getURL = "http://www.google.com";
    HttpGet get = new HttpGet(getURL);
    HttpResponse responseGet = client.execute(get);  
    HttpEntity resEntityGet = responseGet.getEntity();  
    if (resEntityGet != null) {  
                Log.i("GET RESPONSE",EntityUtils.toString(resEntityGet));
            }
 } catch (Exception e) {
   e.printStackTrace();
 }

© Stack Overflow or respective owner

Related posts about java

Related posts about http