Package org.java_websocket.util
Class Charsetfunctions
- java.lang.Object
-
- org.java_websocket.util.Charsetfunctions
-
public class Charsetfunctions extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static CodingErrorActioncodingErrorAction
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]asciiBytes(String s)static booleanisValidUTF8(ByteBuffer data)Calling isValidUTF8 with offset 0static booleanisValidUTF8(ByteBuffer data, int off)Check if the provided BytebBuffer contains a valid utf8 encoded string.static StringstringAscii(byte[] bytes)static StringstringAscii(byte[] bytes, int offset, int length)static StringstringUtf8(byte[] bytes)static StringstringUtf8(ByteBuffer bytes)static byte[]utf8Bytes(String s)
-
-
-
Field Detail
-
codingErrorAction
public static CodingErrorAction codingErrorAction
-
-
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)
-
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 ByteBufferoff- 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
-
-