StringBuilder (@NotNull CharSequence text, @NotNull StringBuilder builder) { for (int i = 0; i < text.length(); i++) { final char c = text.charAt(i); if (c == ' ' || Character.isLetter(c) || Character.isDigit(c) || c == '_') { builder.append(c); } else if (c == '\n') { builder.append("\\n"); } else if (c == '\r') { builder.append("\\r"); } else { final Character.UnicodeBlock block = Character.UnicodeBlock.of(c); if (block == Character.UnicodeBlock.HIGH_SURROGATES || block == Character.UnicodeBlock.LOW_SURROGATES) { builder.append(c); } else { builder.append('\\').append(c); } } } return builder; }