Package org.java_websocket.util
Class Charsetfunctions
java.lang.Object
org.java_websocket.util.Charsetfunctions
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
asciiBytes
(String s) static boolean
isValidUTF8
(ByteBuffer data) Calling isValidUTF8 with offset 0static boolean
isValidUTF8
(ByteBuffer data, int off) Check if the provided BytebBuffer contains a valid utf8 encoded string.static String
stringAscii
(byte[] bytes) static String
stringAscii
(byte[] bytes, int offset, int length) static String
stringUtf8
(byte[] bytes) static String
stringUtf8
(ByteBuffer bytes) static byte[]
-
Method Details
-
utf8Bytes
-
asciiBytes
-
stringAscii
-
stringAscii
-
stringUtf8
- Throws:
InvalidDataException
-
stringUtf8
- Throws:
InvalidDataException
-
isValidUTF8
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
Calling isValidUTF8 with offset 0- Parameters:
data
- the ByteBuffer- Returns:
- does the ByteBuffer contain a valid utf8 encoded string
-