@Test @DisplayName("Method escape replaces the ocatal escape sequences to their corresponding character") void testOctalEscape() { for (int i = 1; i < 256; i++) { int k = i; String oct = ""; while (k > 0) { oct = "" + k % 8 + oct; k /= 8; } assertThat(Escape.escape("this is a \\" + oct + " octal char")) .isEqualTo("this is a " + Character.toString((char)i) + " octal char"); } }
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(); }    }