private static final void appendEncodedByte(StringBuffer buffer,byte value,byte[] state){
  if (state[0] != 0) {
    char c=(char)((state[1] << 8) | (((int)value) & 0xFF));
    buffer.append(c);
    state[0]=0;
  }
 else {
    state[0]=1;
    state[1]=value;
  }
}

private static final void appendEncodedByte ( StringBuffer buffer , byte value , byte [ ] state ) { if ( state [ 0 ] != 0 ) { char c = ( char ) ( ( state [ 1 ] << 8 ) | ( ( ( int ) value ) & 0xFF ) ) ; buffer . append ( c ) ; state [ 0 ] = 0 ; } else { state [ 0 ] = 1 ; state [ 1 ] = value ; } }
append a byte to the given stringbuffer , packing two bytes into each character . the state parameter maintains intermediary data between calls .
