org.apache.shindig.gadgets.encoding
Class EncodingDetector
java.lang.Object
org.apache.shindig.gadgets.encoding.EncodingDetector
public final class EncodingDetector
- extends Object
Attempts to determine the encoding of a given string.
Highly skewed towards common encodings (UTF-8 and Latin-1).
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
detectEncoding
public static Charset detectEncoding(byte[] input,
boolean assume88591IfNotUtf8,
EncodingDetector.FallbackEncodingDetector alternateDecoder)
- Returns the detected encoding of the given byte array.
- Parameters:
input - The data to detect the encoding for.assume88591IfNotUtf8 - True to assume that the encoding is ISO-8859-1 (the standard
encoding for HTTP) if the bytes are not valid UTF-8. Only recommended if you can reasonably
expect that other encodings are going to be specified. Full encoding detection is very
expensive!alternateDecoder - specify a fallback encoding detection.
Only used if assume88591IfNotUtf8 is false.
- Returns:
- The detected encoding.
Copyright © 2007-2012. All Rights Reserved.