private static int decodeOctets ( int i , ByteBuffer bb , StringBuilder sb ) { // If there is only one octet and is an ASCII character if ( bb . limit ( ) == 1 && ( bb . get ( 0 ) & 0xFF ) < 0x80 ) { // Octet can be appended directly sb . append ( ( char ) bb . get ( 0 ) ) ; return i + 2 ; } else { // CharBuffer cb = UTF_8_CHARSET . decode ( bb ) ; sb . append ( cb . toString ( ) ) ; return i + bb . limit ( ) * 3 - 1 ; } }
Decodes octets to characters using the UTF - 8 decoding and appends the characters to a StringBuffer .