Class StandardHtmlEncodingDetector
java.lang.Object
org.apache.tika.parser.html.charsetdetector.StandardHtmlEncodingDetector
- All Implemented Interfaces:
Serializable,org.apache.tika.detect.EncodingDetector
public final class StandardHtmlEncodingDetector
extends Object
implements org.apache.tika.detect.EncodingDetector
An encoding detector that tries to respect the spirit of the HTML spec
part 12.2.3 "The input byte stream", or at least the part that is compatible with
the implementation of tika.
https://html.spec.whatwg.org/multipage/parsing.html#the-input-byte-stream
If a resource was fetched over HTTP, then HTTP headers should be added to tika metadata
when using detect(java.io.InputStream, org.apache.tika.metadata.Metadata), especially HttpHeaders.CONTENT_TYPE, as it may contain
charset information.
This encoding detector may return null if no encoding is detected.
It is meant to be used inside a CompositeEncodingDetector.
For instance:
EncodingDetector detector = new CompositeEncodingDetector(
Arrays.asList(
new StandardHtmlEncodingDetector(),
new Icu4jEncodingDetector()));
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondetect(InputStream input, org.apache.tika.metadata.Metadata metadata) intvoidsetMarkLimit(int markLimit) How far into the stream to read for charset detection.
-
Constructor Details
-
StandardHtmlEncodingDetector
public StandardHtmlEncodingDetector()
-
-
Method Details
-
detect
public Charset detect(InputStream input, org.apache.tika.metadata.Metadata metadata) throws IOException - Specified by:
detectin interfaceorg.apache.tika.detect.EncodingDetector- Throws:
IOException
-
getMarkLimit
public int getMarkLimit() -
setMarkLimit
@Field public void setMarkLimit(int markLimit) How far into the stream to read for charset detection. Default is 8192.
-