Class StringEscaper

java.lang.Object
dev.toonformat.jtoon.util.StringEscaper

public final class StringEscaper extends Object
Handles string escaping for TOON format. Escapes special characters that need protection in quoted strings.
  • Method Details

    • escape

      public static String escape(String value)
      Escapes special characters in a string. Handles backslashes, quotes, and control characters.
      Parameters:
      value - The string to escape
      Returns:
      The escaped string
    • validateString

      public static void validateString(String value)
      Validates a quoted string for invalid escape sequences and unterminated strings.
      Parameters:
      value - The string to validate
      Throws:
      IllegalArgumentException - if the string has invalid escape sequences or is unterminated
    • unescape

      public static String unescape(String value)
      Unescapes a string and removes surrounding quotes if present. Reverses the escaping applied by escape(String).
      Parameters:
      value - The string to unescape (may be quoted)
      Returns:
      The unescaped string with quotes removed