String (@NotNull String text) { StringBuilder buffer = new StringBuilder(); boolean escaped = false; for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (c == ESCAPE_SYMBOL && !escaped && (i == text.length() - 1 || (text.charAt(i + 1) != 'u' && text.charAt(i + 1) != 'U'))) { escaped = true; continue; } if (escaped && (c == 'n' || c == 'r')) { buffer.append(ESCAPE_SYMBOL); } buffer.append(c); escaped = false; } return buffer.toString(); }