|
SMILA (incubation) API documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.smila.utils.file.EncodingHelper
public final class EncodingHelper
Utility class to help with common encoding problems.
Field Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Method Detail |
---|
public static java.lang.String convertToString(byte[] bytes) throws java.io.IOException
bytes
- the bytes to convert to String
java.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 in
null
if encoding could not be detected
java.io.IOException
- if any error occurpublic static java.lang.String getEncodingFromBOM(byte[] bom)
bom
- the byte[] to detect a BOM in
null
if encoding could not be detectedpublic static byte[] removeBOM(byte[] originalBytes)
originalBytes
- the bytes to check for and remove the BOM
public static java.lang.String getEncodingFromContent(byte[] bytes) throws java.io.IOException
bytes
- the byte[] to detect a encoding in
null
if encoding could not be detected
java.io.IOException
- if any error occurpublic static boolean isMarkup(byte[] bytes) throws java.io.IOException
bytes
- the byte[] to check for markup content
java.io.IOException
- if any error occurs
|
SMILA (incubation) API documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |