如何解码android中的特殊字符?

如何解码android中的特殊字符?,android,encoding,utf-8,character-encoding,xml-parsing,Android,Encoding,Utf 8,Character Encoding,Xml Parsing,在我的android应用程序中,我使用套接字并得到一个XML作为响应。我得到的XML如下所示: <response> <result> <id>90</id> <name>J�nna</name> </result> </response>�� 我尝试使用以下代码解码此字符串: String str = URLDecoder.decode(r

在我的android应用程序中,我使用套接字并得到一个XML作为响应。我得到的XML如下所示:

 <response>
     <result>
        <id>90</id>
        <name>J�nna</name>
     </result>
 </response>��
我尝试使用以下代码解码此字符串:

 String str = URLDecoder.decode(response, "UTF-8");

但这没有任何区别。绳子看起来还是一样。由于这些字符,我无法解析这个字符串。你知道我该怎么解决吗?我搜索了很多,找到的任何解决方案都不起作用。提前感谢。

尝试此方法以支持UTF-8的响应

public String getResponseBody(final HttpEntity entity) throws IOException, ParseException {

        if (entity == null) {
            throw new IllegalArgumentException("HTTP entity may not be null");
        }

        InputStream instream = entity.getContent();

        if (instream == null) {
            return "";
        }

        if (entity.getContentLength() > Integer.MAX_VALUE) {
            throw new IllegalArgumentException(

            "HTTP entity too large to be buffered in memory");
        }

        StringBuilder buffer = new StringBuilder();

        BufferedReader reader = new BufferedReader(new InputStreamReader(instream, HTTP.UTF_8));
        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                buffer.append(line);
            }

        } finally {
            instream.close();
            reader.close();
        }
        return buffer.toString();

    }

在接收字符串的位置张贴代码。在其中创建响应值
public String getResponseBody(final HttpEntity entity) throws IOException, ParseException {

        if (entity == null) {
            throw new IllegalArgumentException("HTTP entity may not be null");
        }

        InputStream instream = entity.getContent();

        if (instream == null) {
            return "";
        }

        if (entity.getContentLength() > Integer.MAX_VALUE) {
            throw new IllegalArgumentException(

            "HTTP entity too large to be buffered in memory");
        }

        StringBuilder buffer = new StringBuilder();

        BufferedReader reader = new BufferedReader(new InputStreamReader(instream, HTTP.UTF_8));
        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                buffer.append(line);
            }

        } finally {
            instream.close();
            reader.close();
        }
        return buffer.toString();

    }