Package org.rypt.f8

Class Utf8Statistics

    • Constructor Detail

      • Utf8Statistics

        public Utf8Statistics()
    • Method Detail

      • reset

        public void reset()
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
        Overrides:
        write in class OutputStream
      • handleCodePoint

        public void handleCodePoint​(int codePoint)
        Description copied from interface: Utf8Handler
        Called when a valid unicode code point is encountered
        Specified by:
        handleCodePoint in interface Utf8Handler<RuntimeException>
        Parameters:
        codePoint - the code point that was encountered
      • handle3ByteCodePoint

        public void handle3ByteCodePoint​(int b1,
                                         int b2,
                                         int b3)
        Description copied from interface: Utf8ByteHandler
        Called when a valid 3-byte sequence is encountered.
        Specified by:
        handle3ByteCodePoint in interface Utf8ByteHandler<RuntimeException>
        Specified by:
        handle3ByteCodePoint in interface Utf8Handler<RuntimeException>
        Parameters:
        b1 - the prefix byte, in the range (byte)0xE0-(byte)0xEF
        b2 - the first continuation byte, in the range (byte)0x80-(byte)0xBF, unless the prefix byte is (byte)0xED or (byte)0xE0, in which case the range is (byte)0x80-(byte)0x9F or (byte)0xA0-(byte)0xBF, respectively
        b3 - the second continuation byte, in the range (byte)0x80-(byte)0xBF
        See Also:
        Utf8.codePoint(int, int, int)
      • handle4ByteCodePoint

        public void handle4ByteCodePoint​(int b1,
                                         int b2,
                                         int b3,
                                         int b4)
        Description copied from interface: Utf8ByteHandler
        Called when a valid 4-byte sequence is encountered.
        Specified by:
        handle4ByteCodePoint in interface Utf8ByteHandler<RuntimeException>
        Specified by:
        handle4ByteCodePoint in interface Utf8Handler<RuntimeException>
        Parameters:
        b1 - the prefix byte, in the range (byte)0xF0-(byte)0xF4
        b2 - the first continuation byte, in the range (byte)0x80-(byte)0xBF, unless the prefix byte is (byte)0xF4 or (byte)0xF0, in which case the range is (byte)0x80-(byte)0x8F or (byte)0x90-(byte)0x9F, respectively
        b3 - the second continuation byte, in the range (byte)0x80-(byte)0xBF
        b4 - the third continuation byte, in the range (byte)0x80-(byte)0xBF
        See Also:
        Utf8.codePoint(int, int, int, int)
      • countCodePoints

        public long countCodePoints()
        Returns:
        the total number of valid UTF-8 code points encountered
      • countInvalid

        public long countInvalid()
        Returns:
        the number of invalid UTF-8 byte sequences encountered
      • countInvalidIgnoringTruncation

        public long countInvalidIgnoringTruncation()
        Returns:
        the number of invalid UTF-8 byte sequences encountered, ignoring a final invalid byte sequence that could have been valid given more bytes
      • countAscii

        public long countAscii()
        Returns:
        the number of bytes encountered with a leading 0-bit (i.e., those in the range 0-0x7F)
      • count2Byte

        public long count2Byte()
        Returns:
        the number of 2-byte UTF-8 characters encountered (i.e., those in the range 0x80-0x7FF)
      • count3Byte

        public long count3Byte()
        Returns:
        the number of 3-byte UTF-8 characters encountered (i.e., those in the range 0x800-0xFFFF)
      • count4Byte

        public long count4Byte()
        Returns:
        the number of 4-byte UTF-8 characters encountered (i.e., those in the range 0x10000-0x10FFFF)
      • looksLikeUtf8

        public boolean looksLikeUtf8()
        Returns:
        true if the encountered byte sequence looks like UTF-8 (and not plain ASCII)