Class UtfUtil

java.lang.Object
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 Details

    • 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:
  • Constructor Details

    • UtfUtil

      public UtfUtil()
  • Method Details

    • 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.