@Test @DisplayName("Method escape replaces the usual escape sequences to their corresponding character") void testUsualEscape() { assertThat(Escape.escape("new line\\nline feed\\rtab-character\\t" + "backspace\\bform-feed\\fbackslash\\\\" + "apostrophe\\'quote\\\"")) .isEqualTo("new line\nline feed\rtab-character\t" + "backspace\bform-feed\fbackslash\\" + "apostrophe'quote\""); }
static String escape(String original) { final var sb = new StringBuilder(original); final var output = new StringBuilder(); final var ignored = new StringBuilder(); while (sb.length() > 0) { final char ch = sb.charAt(0); if (ch == '\\') { handleEscape(sb, output, ignored); } else { output.append(ch); sb.deleteCharAt(0); } } return output.toString(); }
Escape { static String escape(String original) { final var sb = new StringBuilder(original); final var output = new StringBuilder(); final var ignored = new StringBuilder(); while (sb.length() > 0) { final char ch = sb.charAt(0); if (ch == '\\') { handleEscape(sb, output, ignored); } else { output.append(ch); sb.deleteCharAt(0); } } return output.toString(); } }
Escape { static String escape(String original) { final var sb = new StringBuilder(original); final var output = new StringBuilder(); final var ignored = new StringBuilder(); while (sb.length() > 0) { final char ch = sb.charAt(0); if (ch == '\\') { handleEscape(sb, output, ignored); } else { output.append(ch); sb.deleteCharAt(0); } } return output.toString(); }  }
Escape { static String escape(String original) { final var sb = new StringBuilder(original); final var output = new StringBuilder(); final var ignored = new StringBuilder(); while (sb.length() > 0) { final char ch = sb.charAt(0); if (ch == '\\') { handleEscape(sb, output, ignored); } else { output.append(ch); sb.deleteCharAt(0); } } return output.toString(); }   }
Escape { static String escape(String original) { final var sb = new StringBuilder(original); final var output = new StringBuilder(); final var ignored = new StringBuilder(); while (sb.length() > 0) { final char ch = sb.charAt(0); if (ch == '\\') { handleEscape(sb, output, ignored); } else { output.append(ch); sb.deleteCharAt(0); } } return output.toString(); }    }