Package com.jalios.io.mimetype
Class UtfUtil
- java.lang.Object
-
- com.jalios.io.mimetype.UtfUtil
-
public class UtfUtil extends java.lang.Object
Utility methods and classes for handling UTF (Unicode Transformation Format) streams. Licence concern : This method is based upon Aperture MagicMimeTypeIdentifier. The code was modified at the margin to be compatible with JRE 1.4.2. Given the licence of Aperture : Open Software Licence (OSL), this modified code of Aperture classes are held at the disposal on demand at support@jalios.com Concerned classes :UtfUtil
MagicNumber
MagicMimeTypeIdentifier
MagicString
MagicNumber
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_BOM_LENGTH
static byte[]
UTF16BE_BOM
static byte[]
UTF16LE_BOM
static byte[]
UTF32BE_BOM
static byte[]
UTF32LE_BOM
static byte[]
UTF8_BOM
-
Constructor Summary
Constructors Constructor Description UtfUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
findMatchingBOM(byte[] bytes)
Determines whether the specified byte array starts with a UTF Byte Order Mark and, if so, returns the matching BOM constant.static java.lang.String
getCharsetName(byte[] byteOrderMark)
Returns the canonical charset name consistent with the specified Byte Order Mark.
-
-
-
Field Detail
-
UTF8_BOM
public static final byte[] UTF8_BOM
-
UTF16BE_BOM
public static final byte[] UTF16BE_BOM
-
UTF16LE_BOM
public static final byte[] UTF16LE_BOM
-
UTF32BE_BOM
public static final byte[] UTF32BE_BOM
-
UTF32LE_BOM
public static final byte[] UTF32LE_BOM
-
MAX_BOM_LENGTH
public static final int MAX_BOM_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
findMatchingBOM
public static byte[] findMatchingBOM(byte[] bytes)
Determines whether the specified byte array starts with a UTF Byte Order Mark and, if so, returns the matching BOM constant.- Parameters:
bytes
- The byte array that is tested for the presence of a UTF Byte Order Mark.- Returns:
- The Byte Order Mark found at the start of the array (one of the constants in this class) or 'null' when a Byte Order Mark could not be found.
-
getCharsetName
public static java.lang.String getCharsetName(byte[] byteOrderMark)
Returns the canonical charset name consistent with the specified Byte Order Mark.- Parameters:
byteOrderMark
- A Unicode Byte Order Mark.- Returns:
- A canonical charset name, or null when the Byte Order Mark was not recognized.
-
-