public abstract class CharsetDetector
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
CHARSET_TOKEN |
static java.lang.String |
DEFAULT_CHARSET
the default charset name to use when giving up
|
protected static java.lang.String |
HTTP_CONTENT_TYPE_HEADER |
protected static int |
MAX_CHARSET_READAHEAD |
| Constructor and Description |
|---|
CharsetDetector() |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
contentTypeToCharset(java.lang.String contentType) |
static java.lang.String |
findMetaContentType(java.lang.String pageSample) |
abstract java.lang.String |
getCharset(byte[] buffer,
int len,
HttpHeaders headers) |
protected java.lang.String |
getCharsetFromBytes(byte[] buffer,
int len)
Attempts to figure out the character set of the document using
the excellent juniversalchardet library.
|
protected java.lang.String |
getCharsetFromHeaders(HttpHeaders headers)
Attempt to divine the character encoding of the document from the
Content-Type HTTP header (with a "charset=")
|
protected java.lang.String |
getCharsetFromMeta(byte[] buffer,
int len)
Attempt to find a META tag in the HTML that hints at the character set
used to write the document.
|
protected boolean |
isCharsetSupported(java.lang.String charsetName) |
protected java.lang.String |
mapCharset(java.lang.String orig) |
protected static final int MAX_CHARSET_READAHEAD
protected static final java.lang.String CHARSET_TOKEN
protected static final java.lang.String HTTP_CONTENT_TYPE_HEADER
public static final java.lang.String DEFAULT_CHARSET
protected boolean isCharsetSupported(java.lang.String charsetName)
protected java.lang.String mapCharset(java.lang.String orig)
protected java.lang.String contentTypeToCharset(java.lang.String contentType)
protected java.lang.String getCharsetFromHeaders(HttpHeaders headers) throws java.io.IOException
resource - java.io.IOExceptionprotected java.lang.String getCharsetFromMeta(byte[] buffer,
int len)
throws java.io.IOException
resource - java.io.IOExceptionpublic static java.lang.String findMetaContentType(java.lang.String pageSample)
protected java.lang.String getCharsetFromBytes(byte[] buffer,
int len)
throws java.io.IOException
resource - java.io.IOExceptionpublic abstract java.lang.String getCharset(byte[] buffer,
int len,
HttpHeaders headers)
throws java.io.IOException
resource - (presumably text) Resource to determine the charsetrequest - WaybackRequest which may contain additional hints to
processingjava.io.IOException - if there are problems reading the ResourceCopyright © 2019 The International Internet Preservation Consortium. All Rights Reserved.