0

如何使用 Android Volley API 获取页面源代码中的阿拉伯语文本?

谢谢!

4

1 回答 1

1

是否有可能更改返回的默认字符集com.android.volley.toolbox.HttpHeaderParser并且该方法parseCharset可以帮助您?

就像是

   /**
     * Returns the charset specified in the Content-Type of this header, or the
     * UTF-8 if none can be found.
     */
    public static String parseCharset(Map<String, String> headers) {
        String contentType = headers.get(HTTP.CONTENT_TYPE);
        if (contentType != null) {
            String[] params = contentType.split(";");
            for (int i = 1; i < params.length; i++) {
                String[] pair = params[i].trim().split("=");
                if (pair.length == 2) {
                    if (pair[0].equals("charset")) {
                        return pair[1];
                    }
                }
            }
        }
        return HTTP.UTF_8;
    }
于 2013-07-14T13:38:17.180 回答