public static boolean escapeUnprintable(StringBuffer result,int c){
  if (isUnprintable(c)) {
    result.append('\\');
    if ((c & ~0xFFFF) != 0) {
      result.append('U');
      result.append(DIGITS[0xF & (c >> 28)]);
      result.append(DIGITS[0xF & (c >> 24)]);
      result.append(DIGITS[0xF & (c >> 20)]);
      result.append(DIGITS[0xF & (c >> 16)]);
    }
 else {
      result.append('u');
    }
    result.append(DIGITS[0xF & (c >> 12)]);
    result.append(DIGITS[0xF & (c >> 8)]);
    result.append(DIGITS[0xF & (c >> 4)]);
    result.append(DIGITS[0xF & c]);
    return true;
  }
  return false;
}

public static boolean escapeUnprintable ( StringBuffer result , int c ) { if ( isUnprintable ( c ) ) { result . append ( '\\' ) ; if ( ( c & ~ 0xFFFF ) != 0 ) { result . append ( 'U' ) ; result . append ( DIGITS [ 0xF & ( c > > 28 ) ] ) ; result . append ( DIGITS [ 0xF & ( c > > 24 ) ] ) ; result . append ( DIGITS [ 0xF & ( c > > 20 ) ] ) ; result . append ( DIGITS [ 0xF & ( c > > 16 ) ] ) ; } else { result . append ( 'u' ) ; } result . append ( DIGITS [ 0xF & ( c > > 12 ) ] ) ; result . append ( DIGITS [ 0xF & ( c > > 8 ) ] ) ; result . append ( DIGITS [ 0xF & ( c > > 4 ) ] ) ; result . append ( DIGITS [ 0xF & c ] ) ; return true ; } return false ; }
escape unprintable characters using < backslash > uxxxx notation for u + 0000 to u + ffff and < backslash > uxxxxxxxx for u + 10000 and above . if the character is printable ascii , then do nothing and return false . otherwise , append the escaped notation and return true .
