static S singleQuote(O o) { if (o == null) return "null"; ret singleQuote(str(o)); } static S singleQuote(S s) { if (s == null) return "null"; StringBuilder out = new StringBuilder((int) (l(s)*1.5+2)); singleQuote_impl(s, out); ret out.toString(); } static void singleQuote_impl(S s, StringBuilder out) { out.append('\''); int l = s.length(); for (int i = 0; i < l; i++) { char c = s.charAt(i); if (c == '\\' || c == '\'') out.append('\\').append(c); else if (c == '\r') out.append("\\r"); else if (c == '\n') out.append("\\n"); else out.append(c); } out.append('\''); }