Charset detectBOM() {
        try {
            if (expect(UTF8_BOM)) {
                return StandardCharsets.UTF_8;
            } else if (expect(UTF16_BE_BOM)) {
                return StandardCharsets.UTF_16BE;
            } else if (expect(UTF16_LE_BOM)) {
                return StandardCharsets.UTF_16LE;
            }
        } catch (IOException e) { /* stream could not be read, also return null */ }
        return null;
    }
A scanner meant to detect charset meta tags in a byte stream
See: https://html.spec.whatwg.org/multipage/parsing.html#prescan-a-byte-stream-to-determine-its-encoding
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-html-module/src/main/java/org/apache/tika/parser/html/charsetdetector/PreScanner.java