private Charset findCharset(String s) {

        Matcher equiv = HTTP_META_PATTERN.matcher(s);
        Matcher charsetMatcher = FLEXIBLE_CHARSET_ATTR_PATTERN.matcher("");
        //iterate through meta tags
        while (equiv.find()) {
            String attrs = equiv.group(1);
            charsetMatcher.reset(attrs);
            //iterate through charset= and return the first match
            //that is valid
            while (charsetMatcher.find()) {
                String candCharset = charsetMatcher.group(1);
                if (CHARSETS_UNSUPPORTED_BY_IANA.contains(candCharset.toLowerCase(Locale.US))) {
                    continue;
                }
                if ("x-user-defined".equalsIgnoreCase(candCharset)) {
                    candCharset = "windows-1252";
                }

                if (CharsetUtils.isSupported(candCharset)) {
                    try {
                        return CharsetUtils.forName(candCharset);
                    } catch (IllegalArgumentException e) {
                        //ignore
                    }
                }
            }
        }
        return null;
    }
HTML can include non-iana supported charsets that Java
recognizes, e.g. "unicode".  This can lead to incorrect detection/mojibake.
Ignore charsets in html meta-headers that are not supported by IANA.
See: TIKA-2592
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-html-module/src/main/java/org/apache/tika/parser/html/HtmlEncodingDetector.java