Class Charsetfunctions

java.lang.Object
org.java_websocket.util.Charsetfunctions

public class Charsetfunctions extends Object
  • Method Details

    • 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)
    • stringUtf8

      public static String stringUtf8(byte[] bytes) throws InvalidDataException
      Throws:
      InvalidDataException
    • stringUtf8

      public static String stringUtf8(ByteBuffer bytes) throws InvalidDataException
      Throws:
      InvalidDataException
    • 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