private static String convertStringToJava(String value, boolean ascii) {
    char[] arr = value.toCharArray();
    StringBuilder buffer = new StringBuilder(arr.length);

    for (char c : arr) {
      switch (c) {
        case '\\' -> //  u005c: backslash \
          buffer.append("\\\\");
        case 0x8 -> // "\\\\b");  //  u0008: backspace BS
          buffer.append("\\b");
        case 0x9 -> //"\\\\t");  //  u0009: horizontal tab HT
          buffer.append("\\t");
        case 0xA -> //"\\\\n");  //  u000a: linefeed LF
          buffer.append("\\n");
        case 0xC -> //"\\\\f");  //  u000c: form feed FF
          buffer.append("\\f");
        case 0xD -> //"\\\\r");  //  u000d: carriage return CR
          buffer.append("\\r");
        case 0x22 -> //"\\\\\""); // u0022: double quote "
          buffer.append("\\\"");

        default -> {
          if (isPrintableAscii(c) || !ascii && TextUtil.isPrintableUnicode(c)) {
            buffer.append(c);
          }
          else {
            buffer.append(TextUtil.charToUnicodeLiteral(c));
          }
        }
      }
    }

    return buffer.toString();
  }
private static String convertStringToJava(String value, boolean ascii)