private String escapify(String s){
  StringBuilder result=new StringBuilder(s.length() * 2);
  for (int i=0; i < s.length(); i++) {
    char c=s.charAt(i);
switch (c) {
case '\'':
      result.append("\\\'");
    break;
case '\"':
  result.append("\\\"");
break;
case '\\':
result.append("\\\\");
break;
case '\t':
result.append("\\t");
break;
case '\r':
if (i + 1 == s.length() || s.charAt(i + 1) != '\n') result.append("\"+ZZ_NL+\"");
break;
case '\n':
result.append("\"+ZZ_NL+\"");
break;
default :
result.append(c);
}
}
return result.toString();
}

private String escapify ( String s ) { StringBuilder result = new StringBuilder ( s . length ( ) * 2 ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; switch ( c ) { case '\'' : result . append ( "\\\'" ) ; break ; case '\"' : result . append ( "\\\"" ) ; break ; case '\\' : result . append ( "\\\\" ) ; break ; case '\t' : result . append ( "\\t" ) ; break ; case '\r' : if ( i + 1 == s . length ( ) || s . charAt ( i + 1 ) != '\n' ) result . append ( "\"+ZZ_NL+\"" ) ; break ; case '\n' : result . append ( "\"+ZZ_NL+\"" ) ; break ; default : result . append ( c ) ; } } return result . toString ( ) ; }
escapes all " ' \ tabs and newlines
