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