/**
* get response charset
*
* @param responseBody
* @return
*/
private String getResponseCharset(String responseBody) {
String charset = "UTF-8";
String regex = "^(.*)(<meta\\s+http-equiv=\"Content-Type\"\\s+content=\"text/html;\\s*charset=)(\\w+(-?\\w)*)(\"\\s+/>.*)$";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(responseBody);
if (m.matches()) {
charset = responseBody.replaceAll(regex, "$3");
}
return charset;
}
meta标签中获取charset
最新推荐文章于 2021-04-05 02:54:57 发布