Package org.java_websocket.util
Class Charsetfunctions
- java.lang.Object
-
- org.java_websocket.util.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 0static 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)
-
-
-
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)
-
stringUtf8
public static java.lang.String stringUtf8(byte[] bytes) throws InvalidDataException
- Throws:
InvalidDataException
-
stringUtf8
public static java.lang.String stringUtf8(java.nio.ByteBuffer bytes) throws InvalidDataException
- Throws:
InvalidDataException
-
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 ByteBufferoff
- 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
-
-