public static String quote(char ch){
switch (ch) {
case '\b':
    return "\\b";
case '\f':
  return "\\f";
case '\n':
return "\\n";
case '\r':
return "\\r";
case '\t':
return "\\t";
case '\'':
return "\\'";
case '\"':
return "\\\"";
case '\\':
return "\\\\";
default :
return (isPrintableAscii(ch)) ? String.valueOf(ch) : String.format("\\u%04x",(int)ch);
}
}

public static String quote ( char ch ) { switch ( ch ) { case '\b' : return "\\b" ; case '\f' : return "\\f" ; case '\n' : return "\\n" ; case '\r' : return "\\r" ; case '\t' : return "\\t" ; case '\'' : return "\\'" ; case '\"' : return "\\\"" ; case '\\' : return "\\\\" ; default : return ( isPrintableAscii ( ch ) ) ? String . valueOf ( ch ) : String . format ( "\\u%04x" , ( int ) ch ) ; } }
escapes a character if it has an escape sequence or is non - printable ascii . leaves non - ascii characters alone .
