void () { char nextChar; if (myCursor == myTemplate.length()) throw new IllegalArgumentException("character to be escaped is missing"); nextChar = myTemplate.charAt(myCursor++); switch (nextChar) { case 'n' -> myReplacement.append('\n'); case 'r' -> myReplacement.append('\r'); case 'b' -> myReplacement.append('\b'); case 't' -> myReplacement.append('\t'); case 'f' -> myReplacement.append('\f'); case 'x' -> { if (myCursor + 4 <= myTemplate.length()) { try { int code = Integer.parseInt(myTemplate.substring(myCursor, myCursor + 4), 16); myCursor += 4; myReplacement.append((char)code); } catch (NumberFormatException ignored) {} } } case 'l' -> startConversionForCharacter(false); case 'u' -> startConversionForCharacter(true); case 'L' -> startConversionForRegion(false); case 'U' -> startConversionForRegion(true); case 'E' -> resetConversionState(); default -> myReplacement.append(nextChar); } }