org.gjt.sp.jedit.io
Class RegexEncodingDetector
java.lang.Object
org.gjt.sp.jedit.io.RegexEncodingDetector
- All Implemented Interfaces:
- EncodingDetector
public class RegexEncodingDetector
- extends java.lang.Object
- implements EncodingDetector
An encoding detector which finds regex pattern.
This reads the sample in the system default encoding for first some
lines and look for a regex pattern. This can fail if the
stream cannot be read in the system default encoding or the
pattern is not found at near the top of the stream.
- Since:
- 4.3pre16
Field Summary |
static java.lang.String |
VALID_ENCODING_PATTERN
A regex pattern matches to "Charset names" specified for
java.nio.charset.Charset. |
Method Summary |
java.lang.String |
detectEncoding(java.io.InputStream sample)
Returns the name of a detected encoding for the bytes in sample. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
VALID_ENCODING_PATTERN
public static final java.lang.String VALID_ENCODING_PATTERN
- A regex pattern matches to "Charset names" specified for
java.nio.charset.Charset.
- See Also:
- Charset names,
Constant Field Values
RegexEncodingDetector
public RegexEncodingDetector(java.lang.String pattern,
java.lang.String replacement)
detectEncoding
public java.lang.String detectEncoding(java.io.InputStream sample)
throws java.io.IOException
- Description copied from interface:
EncodingDetector
- Returns the name of a detected encoding for the bytes in sample.
Returns null if this instance could not detect reasonable one.
- Specified by:
detectEncoding
in interface EncodingDetector
- Throws:
java.io.IOException