public ByteStringBuilder appendUtf8(final char[] chars){
  if (chars == null) {
    return this;
  }
  final int len=chars.length;
  ensureAdditionalCapacity(len);
  for (int i=0; i < len; i++) {
    final char c=chars[i];
    final byte b=(byte)(c & 0x0000007F);
    if (c == b) {
      buffer[this.length + i]=b;
    }
 else {
      final Charset utf8=Charset.forName("UTF-8");
      final ByteBuffer byteBuffer=utf8.encode(CharBuffer.wrap(chars));
      final int remaining=byteBuffer.remaining();
      ensureAdditionalCapacity(remaining - len);
      byteBuffer.get(buffer,this.length,remaining);
      this.length+=remaining;
      return this;
    }
  }
  this.length+=len;
  return this;
}

public ByteStringBuilder appendUtf8 ( final char [ ] chars ) { if ( chars == null ) { return this ; } final int len = chars . length ; ensureAdditionalCapacity ( len ) ; for ( int i = 0 ; i < len ; i ++ ) { final char c = chars [ i ] ; final byte b = ( byte ) ( c & 0x0000007F ) ; if ( c == b ) { buffer [ this . length + i ] = b ; } else { final Charset utf8 = Charset . forName ( "UTF-8" ) ; final ByteBuffer byteBuffer = utf8 . encode ( CharBuffer . wrap ( chars ) ) ; final int remaining = byteBuffer . remaining ( ) ; ensureAdditionalCapacity ( remaining - len ) ; byteBuffer . get ( buffer , this . length , remaining ) ; this . length += remaining ; return this ; } } this . length += len ; return this ; }
appends the utf - 8 encoded bytes of the provided char array to this byte string builder .
