如何使用 Android Volley API 获取页面源代码中的阿拉伯语文本?
谢谢!
是否有可能更改返回的默认字符集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;
}