Top Fields Constructors Methods
org.java_websocket.util

public Class Charsetfunctions

extends Object
Class Inheritance
Imports
java.nio.ByteBuffer, java.nio.charset.CharacterCodingException, .CharsetDecoder, .CodingErrorAction, .StandardCharsets, org.java_websocket.exceptions.InvalidDataException, org.java_websocket.framing.CloseFrame

Field Summary

Modifier and TypeField and Description
private static final CodingErrorAction
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 Summary

AccessConstructor and Description
private
Charsetfunctions()

Private constructor for real static class

Method Summary

Modifier and TypeMethod and Description
public static byte[]
public static boolean

Returns:

does the ByteBuffer contain a valid utf8 encoded string
isValidUTF8
(ByteBuffer
the ByteBuffer
data
,
int
offset (for performance reasons)
off
)

Check if the provided BytebBuffer contains a valid utf8 encoded string.

public static boolean

Returns:

does the ByteBuffer contain a valid utf8 encoded string
isValidUTF8
(ByteBuffer
the ByteBuffer
data
)

Calling isValidUTF8 with offset 0

public static String
stringAscii(byte[] bytes)

public static String
stringAscii(byte[] bytes, int offset, int length)

public static String
stringUtf8(byte[] bytes)

public static String
public static byte[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

codingErrorActionback to summary
private static final CodingErrorAction codingErrorAction
utf8dback to summary
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

Charsetfunctionsback to summary
private Charsetfunctions()

Private constructor for real static class

Method Detail

asciiBytesback to summary
public static byte[] asciiBytes(String s)
isValidUTF8back to summary
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:ByteBuffer

the ByteBuffer

off:int

offset (for performance reasons)

Returns:boolean

does the ByteBuffer contain a valid utf8 encoded string

isValidUTF8back to summary
public static boolean isValidUTF8(ByteBuffer data)

Calling isValidUTF8 with offset 0

Parameters
data:ByteBuffer

the ByteBuffer

Returns:boolean

does the ByteBuffer contain a valid utf8 encoded string

stringAsciiback to summary
public static String stringAscii(byte[] bytes)
stringAsciiback to summary
public static String stringAscii(byte[] bytes, int offset, int length)
stringUtf8back to summary
public static String stringUtf8(byte[] bytes) throws InvalidDataException
stringUtf8back to summary
public static String stringUtf8(ByteBuffer bytes) throws InvalidDataException
utf8Bytesback to summary
public static byte[] utf8Bytes(String s)