Class Charsetfunctions


  • public class Charsetfunctions
    extends Object
    • Method Detail

      • utf8Bytes

        public static byte[] utf8Bytes​(String s)
      • asciiBytes

        public static byte[] asciiBytes​(String s)
      • stringAscii

        public static String stringAscii​(byte[] bytes)
      • stringAscii

        public static String stringAscii​(byte[] bytes,
                                         int offset,
                                         int length)
      • isValidUTF8

        public static boolean isValidUTF8​(ByteBuffer data,
                                          int off)
        Check if the provided BytebBuffer contains a valid utf8 encoded string.

        Using the algorithm "Flexible and Economical UTF-8 Decoder" by Björn Höhrmann (http://bjoern.hoehrmann.de/utf-8/decoder/dfa/)

        Parameters:
        data - the ByteBuffer
        off - offset (for performance reasons)
        Returns:
        does the ByteBuffer contain a valid utf8 encoded string
      • isValidUTF8

        public static boolean isValidUTF8​(ByteBuffer data)
        Calling isValidUTF8 with offset 0
        Parameters:
        data - the ByteBuffer
        Returns:
        does the ByteBuffer contain a valid utf8 encoded string