public static void quote ( Appendable buffer , String input ) { if ( input == null ) return ; try { buffer . append ( ' ' ) ; for ( int i = 0 ; i < input . length ( ) ; ++ i ) { char c = input . charAt ( i ) ; if ( c >= 32 ) { if ( c == ' ' || c == ' ' ) buffer . append ( ' ' ) ; buffer . append ( c ) ; } else { char escape = escapes [ c ] ; if ( escape == 0xFFFF ) { // Unicode escape buffer . append ( ' ' ) . append ( ' ' ) . append ( ' ' ) . append ( ' ' ) ; if ( c < 0x10 ) buffer . append ( ' ' ) ; buffer . append ( Integer . toString ( c , 16 ) ) ; } else { buffer . append ( ' ' ) . append ( escape ) ; } } } buffer . append ( ' ' ) ; } catch ( IOException x ) { throw new RuntimeException ( x ) ; } }
Quote a string into an Appendable . The characters \ \ n \ r \ t \ f and \ b are escaped