src/main/java/org/java_websocket/util/Charsetfunctions.java
public static boolean isValidUTF8( ByteBuffer data, int off ) {
		int len = data.remaining();
		if( len < off ) {
			return false;
		}
		int state = 0;
		for( int i = off; i < len; ++i ) {
			state = utf8d[256 + ( state << 4 ) + utf8d[( 0xff & data.get( i ) )]];
			if( state == 1 ) {
				return false;
			}
		}
		return true;
	}
public static boolean isValidUTF8( ByteBuffer data, int off ) {
		int len = data.remaining();
		if( len < off ) {
			return false;
		}
		int state = 0;
		for( int i = off; i < len; ++i ) {
			state = utf8d[256 + ( state << 4 ) + utf8d[( 0xff & data.get( i ) )]];
			if( state == 1 ) {
				return false;
			}
		}
		return true;
	}
public static boolean isValidUTF8 ( ByteBuffer data , int off ) { int len = data . remaining ( ) ; if ( len < off ) { return false ; } int state = 0 ; for ( int i = off ; i < len ; ++ i ) { state = utf8d [ 256 + ( state << 4 ) + utf8d [ ( 0xff & data . get ( i ) ) ] ] ; if ( state == 1 ) { return false ; } } return true ; }
Check if the provided BytebBuffer contains a valid utf8 encoded string.
<p>
Using the algorithm "Flexible and Economical UTF-8 Decoder" by Björn Höhrmann (http://bjoern.hoehrmann.de/utf-8/decoder/dfa/)

@param data the ByteBuffer
@param off  offset (for performance reasons)
@return does the ByteBuffer contain a valid utf8 encoded string
Check if the provided BytebBuffer contains a valid utf8 encoded string . <p > Using the algorithm Flexible and Economical UTF - 8 Decoder by Björn Höhrmann ( http : // bjoern . hoehrmann . de / utf - 8 / decoder / dfa / )