Class Charsetfunctions


  • public class Charsetfunctions
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.nio.charset.CodingErrorAction codingErrorAction  
      private static int[] utf8d
      Implementation of the "Flexible and Economical UTF-8 Decoder" algorithm by Björn Höhrmann (http://bjoern.hoehrmann.de/utf-8/decoder/dfa/)
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Charsetfunctions()
      Private constructor for real static class
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] asciiBytes​(java.lang.String s)  
      static boolean isValidUTF8​(java.nio.ByteBuffer data)
      Calling isValidUTF8 with offset 0
      static boolean isValidUTF8​(java.nio.ByteBuffer data, int off)
      Check if the provided BytebBuffer contains a valid utf8 encoded string.
      static java.lang.String stringAscii​(byte[] bytes)  
      static java.lang.String stringAscii​(byte[] bytes, int offset, int length)  
      static java.lang.String stringUtf8​(byte[] bytes)  
      static java.lang.String stringUtf8​(java.nio.ByteBuffer bytes)  
      static byte[] utf8Bytes​(java.lang.String s)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • codingErrorAction

        private static final java.nio.charset.CodingErrorAction codingErrorAction
      • utf8d

        private static final int[] utf8d
        Implementation of the "Flexible and Economical UTF-8 Decoder" algorithm by Björn Höhrmann (http://bjoern.hoehrmann.de/utf-8/decoder/dfa/)
    • Constructor Detail

      • Charsetfunctions

        private Charsetfunctions()
        Private constructor for real static class
    • Method Detail

      • utf8Bytes

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

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

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

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

        public static boolean isValidUTF8​(java.nio.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​(java.nio.ByteBuffer data)
        Calling isValidUTF8 with offset 0
        Parameters:
        data - the ByteBuffer
        Returns:
        does the ByteBuffer contain a valid utf8 encoded string