4

In my Android application I get JSON response string from a PHP url. from the response I get some hotel names with apostrophe, I get &#039 character instead of apostrophe. How can I parse the hotel with special characters in android? I can see the apostrophe in the browser but could not see in android logcat.

I have tried jresponse = URLEncoder.encode(jresponse,"UTF-8"); but I could not get apostrophe for hotel name.

This is the one of the hotel name in the response.

 I see the following in browser.

    {"id":12747,
     "name":"Oscar's",
     ....
    }
But in the logcat:

     id 12747
     name Oscar's
M.A.Murali
  • 9,988
  • 36
  • 105
  • 182

3 Answers3

0

Use the decoder instead of encoder. URLDecoder.decode(jresponse,"UTF-8")

mach
  • 8,315
  • 3
  • 33
  • 51
0

Use ISO-8859-2 when you create the URLEncodedEntity that you send off. You can set this as a parameter in the constructor.

Without a specified charset, you are probably sending the data in UTF-8/UTF-16 (most common) which the server is interpreting in a different way.

EDIT: It looks like ISO-8859-2 doesn't support ñ. You may have to change something server-side. http://en.wikipedia.org/wiki/ISO/IEC_8859-2

Bhanu Sharma
  • 5,135
  • 2
  • 24
  • 49
0

You can try Html class. eg :- jresponse = Html.fromHtml(jresponse);

Arunkrishna
  • 416
  • 1
  • 4
  • 18