public class CharacterEncodingDetector extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ENC_ASCII |
static String |
ENC_EUC_JP |
static String |
ENC_ISO_2022_JP |
static String |
ENC_ISO_8859_1 |
static String |
ENC_SHIFT_JIS |
static String |
ENC_UTF_8 |
static int |
EUC
Flag set if the byte array contains EUC variables.
|
static int |
JIS
Flag set if the byte array contains JIS values.
|
static int |
JIS8
Flag set if the byte array contains 8-bit JIS values.
|
static int |
NONASCII
Flag set if the byte array contains values outside the ASCII character set.
|
static int |
SJIS
Flag set if the byte array contains Shift-JIS values.
|
static int |
UTF8
Flag set if the byte array contains UTF-8 characters.
|
Constructor and Description |
---|
CharacterEncodingDetector() |
Modifier and Type | Method and Description |
---|---|
static InputStreamReader |
getReader(InputStream in)
Creates a reader for the input stream with a character encoding guessed by looking at
the beginning of the stream.
|
static InputStreamReader |
getReader(InputStream in,
String defaultencoding)
Creates a reader for the input stream with a character encoding guessed by looking at
the beginning of the stream.
|
static InputStreamReader |
getReader(InputStream in,
String defaultencoding,
int lookatlength)
Creates a reader for the input stream with a character encoding guessed by looking at
the beginning of the stream.
|
static int |
guessEncoding(byte[] data)
Detects the character encoding used for a byte array.
|
static String |
guessEncodingName(byte[] data)
Detects the character encoding used for a byte array.
|
static int |
guessLength(int dlength,
String encoding)
Guesses the lenght in characters encoded using
encoding as byte array. |
public static final String ENC_ISO_2022_JP
public static final String ENC_EUC_JP
public static final String ENC_SHIFT_JIS
public static final String ENC_UTF_8
public static final String ENC_ISO_8859_1
public static final String ENC_ASCII
public static final int NONASCII
public static final int JIS
public static final int EUC
public static final int SJIS
public static final int JIS8
public static final int UTF8
public static InputStreamReader getReader(InputStream in) throws IOException
in
- An input stream for Japanese characters.IOException
- if an error occurs while reading from the stream.public static InputStreamReader getReader(InputStream in, String defaultencoding) throws IOException
in
- An input stream for Japanese characters.defaultencoding
- The encoding to use when the input stream encoding could not be
determined (currently unused).IOException
- if an error occurs while reading from the stream.public static InputStreamReader getReader(InputStream in, String defaultencoding, int lookatlength) throws IOException
in
- An input stream for Japanese characters.defaultencoding
- The encoding to use when the input stream encoding could not be
determined (currently unused).lookatlength
- Length in bytes the method looks at for detection.IOException
- if an error occurs while reading from the stream.public static int guessLength(int dlength, String encoding)
encoding
as byte array.dlength
- Length in bytes of an array of encoded characters.encoding
- Encoding used.public static String guessEncodingName(byte[] data)
An
- array with encoded Japanese characters.public static int guessEncoding(byte[] data)
data
- An array with encoded Japanese characters.Copyright © 2001-2013 the JGloss developers. All Rights Reserved.