0

Here is the word pronounciation coming in my web services response tækˈsɑ:nəmi but when i show it android textview it shows like this tækËsÉ:nÉmi And also sometime it shows Square boxes in place of some characters when i show it in android textview.

Please guide or suggest some solution.

Ali

Ali Akram
  • 4,803
  • 3
  • 29
  • 38
  • Probably your server isn't sending Unicode UTF8 encoded strings (i.e.: a Windows based server left with the default encoding). – Phantômaxx Feb 16 '15 at 07:37
  • So the correction should be on server side ? – Ali Akram Feb 16 '15 at 07:39
  • Basically I am fetching date from an API server over which I don't have control to change encoding format.Can you suggest something i can do on client side? – Ali Akram Feb 16 '15 at 07:55
  • Maybe this post will help you: http://stackoverflow.com/questions/12040765/android-utf8-encoding-from-received-string – Phantômaxx Feb 16 '15 at 08:09

1 Answers1

0

I have found the way to solve this after consulting with a genius guy.

        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        httpPost.setHeader("Content-Type",
                "application/x-www-form- urlencoded");
        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();

Here is the magical line of code.

        xml = EntityUtils.toString(httpEntity, HTTP.UTF_8);

Cheers. Ali

Ali Akram
  • 4,803
  • 3
  • 29
  • 38