4

在我的 Android 应用程序中,我从 PHP url 获取 JSON 响应字符串。从我得到一些酒店名称的回复中apostrophe,我得到了&#039字符而不是apostrophe。如何在android中解析带有特殊字符的酒店?I can see the apostrophe in the browser but could not see in android logcat.

我试过了jresponse = URLEncoder.encode(jresponse,"UTF-8");,但我找不到apostrophe酒店名称。

这是响应中的酒店名称之一。

 I see the following in browser.

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

     id 12747
     name Oscar's
4

3 回答 3

0

创建发送的 URLEncodedEntity 时使用 ISO-8859-2。您可以将其设置为构造函数中的参数。

如果没有指定的字符集,您可能会以服务器以不同方式解释的 UTF-8/UTF-16(最常见)格式发送数据。

编辑:看起来 ISO-8859-2 不支持ñ。您可能需要在服务器端进行一些更改。http://en.wikipedia.org/wiki/ISO/IEC_8859-2

于 2014-03-10T13:28:41.610 回答
0

使用解码器而不是编码器。URLDecoder.decode(jresponse,"UTF-8")

于 2014-03-10T13:18:38.867 回答
0

您可以尝试 Html 类。例如:- jresponse = Html.fromHtml(jresponse);

于 2016-01-07T14:39:59.680 回答