com.jalios.io.mimetype
Class UtfUtil

java.lang.Object
  extended by com.jalios.io.mimetype.UtfUtil

public class UtfUtil
extends 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
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
UtfUtil()
           
 
Method Summary
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 String getCharsetName(byte[] byteOrderMark)
          Returns the canonical charset name consistent with the specified Byte Order Mark.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

UtfUtil

public UtfUtil()
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 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.


Copyright © 2001-2010 Jalios SA. All Rights Reserved.