question: public int readText ( char [ ] charBuffer , int charOffset , int charLength ) throws IOException { byte [ ] byteBuffer = _is . buffer ( ) ; int byteOffset = _is . offset ( ) ; int byteLength = _is . length ( ) ; if ( byteLength <= byteOffset || length ( ) == 0 ) { if ( ! fillFrameBuffer ( ) ) { return - 1 ; } byteOffset = _is . offset ( ) ; byteLength = _is . length ( ) ; } int charEnd = charOffset + charLength ; int i = charOffset ; int byteBegin = byteOffset ; int byteEnd = ( int ) Math . min ( byteLength , byteOffset + length ( ) ) ; while ( i < charEnd && byteOffset < byteEnd ) { int d1 = byteBuffer [ byteOffset ++ ] & 0xff ; char ch ; if ( d1 < 0x80 ) { ch = ( char ) d1 ; } else if ( ( d1 & 0xe0 ) == 0xc0 ) { int d2 = byteBuffer [ byteOffset ++ ] & 0xff ; ch = ( char ) ( ( ( d1 & 0x1f ) << 6 ) + ( d2 & 0x3f ) ) ; if ( d2 < 0 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } else if ( ( d2 & 0xc0 ) != 0x80 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } else if ( ch < 0x80 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } } else if ( ( d1 & 0xf0 ) == 0xe0 ) { int d2 = byteBuffer [ byteOffset ++ ] & 0xff ; int d3 = byteBuffer [ byteOffset ++ ] & 0xff ; ch = ( char ) ( ( ( d1 & 0x0f ) << 12 ) + ( ( d2 & 0x3f ) << 6 ) + ( d3 & 0x3f ) ) ; if ( d3 < 0 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } else if ( ( d2 & 0xc0 ) != 0x80 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } else if ( ( d3 & 0xc0 ) != 0x80 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } else if ( ch < 0x800 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } else if ( 0xd800 <= ch && ch <= 0xdfff ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } } else if ( ( d1 & 0xf8 ) == 0xf0 ) { int d2 = byteBuffer [ byteOffset ++ ] & 0xff ; int d3 = byteBuffer [ byteOffset ++ ] & 0xff ; int d4 = byteBuffer [ byteOffset ++ ] & 0xff ; int cp = ( ( ( d1 & 0x7 ) << 18 ) + ( ( d2 & 0x3f ) << 12 ) + ( ( d3 & 0x3f ) << 6 ) + ( ( d4 & 0x3f ) ) ) ; cp -= 0x10000 ; char h = ( char ) ( 0xd800 + ( ( cp > > 10 ) & 0x3ff ) ) ; charBuffer [ i ++ ] = h ; ch = ( char ) ( 0xdc00 + ( cp & 0x3ff ) ) ; if ( d4 < 0 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } else if ( ( d2 & 0xc0 ) != 0x80 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } else if ( ( d3 & 0xc0 ) != 0x80 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } else if ( ( d4 & 0xc0 ) != 0x80 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } else if ( cp < 0x0 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } else if ( cp >= 0x100000 ) { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } } else { closeError ( CloseCodes . NOT_CONSISTENT , "illegal utf-8" ) ; ch = UTF8_ERROR ; } charBuffer [ i ++ ] = ch ; } _is . offset ( byteOffset ) ; _length -= ( byteOffset - byteBegin ) ; return i - charOffset ; }
target:  Reads a buffer of text from the current message, returning -1 when the message ends.