Package org.omegat.util
Class EncodingDetector
java.lang.Object
org.omegat.util.EncodingDetector
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringdetectEncoding(File inFile) Detect the encoding of the supplied file.static StringdetectEncoding(InputStream stream) Detect the encoding of the supplied file.static StringdetectEncodingDefault(File inFile, String defaultEncoding) Detect the encoding of the supplied file.static CharsetdetectHtmlEncoding(String fileName, String defaultEncoding) Returns the reader of the underlying file in the correct encoding.
-
Method Details
-
detectEncoding
Detect the encoding of the supplied file. Convenience method fordetectEncoding(java.io.InputStream).- Throws:
IOException
-
detectEncoding
Detect the encoding of the supplied file. The caller is responsible for closing the stream.- Throws:
IOException- See Also:
-
detectEncodingDefault
Detect the encoding of the supplied file. If detection fails, return the supplied default encoding. -
detectHtmlEncoding
Returns the reader of the underlying file in the correct encoding.We can detect the following:
- UTF-16 with BOM (byte order mark)
- UTF-8 with BOM (byte order mark)
- Any other encoding with 8-bit Latin symbols (e.g. Windows-1251, UTF-8 etc), if it is specified using XML/HTML-style encoding declarations.
Note that we cannot detect UTF-16 encoding, if there's no BOM!
-