Open andy-betin opened 7 years ago
Noted and thanks for the example! I'm not keen on adding more dependencies (would like to remove some if possible) but this will be a good starting point to look into the issue and see if we can get comparable functionality like this.
I would like to propose a possible fix for incorrect encoding detection sites.
With
you can fix com.machinepublishers.jbrowserdriver.Util
with next code for auto detect encoding:
static String charset(URLConnection conn) { String charset = conn.getContentType(); if (charset != null) { Matcher matcher = charsetPattern.matcher(charset); if (matcher.find()) { charset = matcher.group(1); if (Charset.isSupported(charset)) { return charset; } } } try { return checkCharset(conn.getInputStream()); }catch (Exception e){ return "utf-8"; }
}
public static String checkCharset(InputStream is){ try {
}