String (String arg) { String specials = " #'\"\n\r\t\f"; if (!StringUtil.containsAnyChar(arg, specials)) { return arg; } @NonNls StringBuilder sb = new StringBuilder(arg.length() * 2); for (int i = 0; i < arg.length(); i++) { char c = arg.charAt(i); if (c == ' ' || c == '#' || c == '\'') sb.append('"').append(c).append('"'); else if (c == '"') sb.append("\"\\\"\""); else if (c == '\n') sb.append("\"\\n\""); else if (c == '\r') sb.append("\"\\r\""); else if (c == '\t') sb.append("\"\\t\""); else if (c == '\f') sb.append("\"\\f\""); else sb.append(c); } return sb.toString(); }