public final class EncodingHelper
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ENCODING_UTF_16BE
Constant for the encoding UTF-16BE.
|
static java.lang.String |
ENCODING_UTF_16LE
Constant for the encoding UTF-16LE.
|
static java.lang.String |
ENCODING_UTF_32BE
Constant for the encoding UTF-32BE.
|
static java.lang.String |
ENCODING_UTF_32LE
Constant for the encoding UTF-32LE.
|
static java.lang.String |
ENCODING_UTF_8
Constant for the encoding UTF-8.
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
convertToString(byte[] bytes)
Converts a given byte[] to a String.
|
static java.lang.String |
getEncoding(byte[] bytes)
Read bytes and detect encoding based on potential BOM marks or xml or html encoding information.
|
static java.lang.String |
getEncodingFromBOM(byte[] bom)
Read bytes and detect encoding based on potential BOM marks.
|
static java.lang.String |
getEncodingFromContent(byte[] bytes)
Read bytes and detect encoding based on potential xml or html encoding information from tags.
|
static boolean |
isMarkup(byte[] bytes)
Checks if the given bytes array represents some kind of markup language (xml, html), by checking if the first non
whitespace character is a <.
|
static boolean |
isSupportedEncoding(java.lang.String charset)
Checks if the given charset is supported by the current java VM.
|
static byte[] |
removeBOM(byte[] originalBytes)
Checks if the originalBytes contain a BOM and Removes the BOM from the byte array.
|
public static final java.lang.String ENCODING_UTF_32BE
public static final java.lang.String ENCODING_UTF_32LE
public static final java.lang.String ENCODING_UTF_8
public static final java.lang.String ENCODING_UTF_16BE
public static final java.lang.String ENCODING_UTF_16LE
public static java.lang.String convertToString(byte[] bytes)
throws java.io.IOException
bytes - the bytes to convert to Stringjava.io.IOException - if any error occurspublic static boolean isSupportedEncoding(java.lang.String charset)
charset - the name of the charset.public static java.lang.String getEncoding(byte[] bytes)
throws java.io.IOException
bytes - the byte[] to detect a encoding innull if encoding could not be detectedjava.io.IOException - if any error occurpublic static java.lang.String getEncodingFromBOM(byte[] bom)
bom - the byte[] to detect a BOM innull if encoding could not be detectedpublic static byte[] removeBOM(byte[] originalBytes)
originalBytes - the bytes to check for and remove the BOMpublic static java.lang.String getEncodingFromContent(byte[] bytes)
throws java.io.IOException
bytes - the byte[] to detect a encoding innull if encoding could not be detectedjava.io.IOException - if any error occurpublic static boolean isMarkup(byte[] bytes)
throws java.io.IOException
bytes - the byte[] to check for markup contentjava.io.IOException - if any error occurs