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