public final class Iso2022Converter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static int |
DOT |
private static byte |
ESC |
private static java.lang.String |
ISO_8859_1 |
private static byte |
LATIN_CAPITAL_A |
private static byte |
LATIN_CAPITAL_G |
private static byte |
PERCENT_SIGN |
private static java.lang.String |
UTF_8 |
Modifier | Constructor and Description |
---|---|
private |
Iso2022Converter() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
convertISO2022CharsetToJavaCharset(byte[] bytes)
Converts the given ISO2022 char set to a Java charset name.
|
(package private) static java.nio.charset.Charset |
guessCharSet(byte[] bytes)
Attempts to guess the
Charset of a string provided as a byte array. |
private static final java.lang.String ISO_8859_1
private static final java.lang.String UTF_8
private static final byte LATIN_CAPITAL_A
private static final int DOT
private static final byte LATIN_CAPITAL_G
private static final byte PERCENT_SIGN
private static final byte ESC
public static java.lang.String convertISO2022CharsetToJavaCharset(byte[] bytes)
bytes
- string data encoded using ISO2022null
if the conversion was not possiblestatic java.nio.charset.Charset guessCharSet(byte[] bytes)
Charset
of a string provided as a byte array.
Charsets trialled are, in order:
System.getProperty("file.encoding")
Its only purpose is to guess the Charset if and only if IPTC tag coded character set is not set. If the encoding is not UTF-8, the tag should be set. Otherwise it is bad practice. This method tries to workaround this issue since some metadata manipulating tools do not prevent such bad practice.
About the reliability of this method: The check if some bytes are UTF-8 or not has a very high reliability. The two other checks are less reliable.
bytes
- some text as bytes