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 Details

    • ASCII_CHARSET

      private static final Charset ASCII_CHARSET
  • Constructor Details

    • ByteOptimizedUTF8Encoder

      ByteOptimizedUTF8Encoder()
  • Method Details

    • decode

      public String decode(byte[] encodedString, int offset, int length) throws 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:
      IOException - if something goes wrong
    • slowDecode

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