Class ByteOptimizedUTF8Encoder


  • final class ByteOptimizedUTF8Encoder
    extends OptimizedUTF8Encoder
    UTF-8 encoder which validates input and is optimized for jdk 9+ where String objects are backed by byte[].
    • Field Detail

      • ASCII_CHARSET

        private static final java.nio.charset.Charset ASCII_CHARSET
    • Constructor Detail

      • ByteOptimizedUTF8Encoder

        ByteOptimizedUTF8Encoder()
    • Method Detail

      • decode

        public java.lang.String decode​(byte[] encodedString,
                                       int offset,
                                       int length)
                                throws java.io.IOException
        Decode an array of bytes into a string.
        Overrides:
        decode in class Encoding
        Parameters:
        encodedString - a byte array containing the string to decode
        offset - the offset in encodedString of the first byte of the encoded representation
        length - the length, in bytes, of the encoded representation
        Returns:
        the decoded string
        Throws:
        java.io.IOException - if something goes wrong
      • slowDecode

        private java.lang.String slowDecode​(byte[] encodedString,
                                            int offset,
                                            int length,
                                            int curIdx)
                                     throws java.io.IOException
        Decodes to char[] in presence of non-ascii values after first copying all known ascii chars directly from byte[] to char[].
        Throws:
        java.io.IOException