HTML

Escape/unescape utility class: org.unbescape.html.HtmlEscape

Configuration
  • Escape Types: org.unbescape.html.HtmlEscapeType
    • HTML4_NAMED_REFERENCES_DEFAULT_TO_DECIMAL
    • HTML4_NAMED_REFERENCES_DEFAULT_TO_HEXA
    • HTML5_NAMED_REFERENCES_DEFAULT_TO_DECIMAL
    • HTML5_NAMED_REFERENCES_DEFAULT_TO_HEXA
    • DECIMAL_REFERENCES
    • HEXADECIMAL_REFERENCES
  • Escape Levels: org.unbescape.html.HtmlEscapeLevel
    • LEVEL_0_ONLY_MARKUP_SIGNIFICANT_EXCEPT_APOS
    • LEVEL_1_ONLY_MARKUP_SIGNIFICANT
    • LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
    • LEVEL_3_ALL_NON_ALPHANUMERIC
    • LEVEL_4_ALL_CHARACTERS
Escaping

Some sample code (see the javadoc for more detail):

final String escaped = HtmlEscape.escapeHtml5(text);
final String escaped = HtmlEscape.escapeHtml4Xml(text);
final String escaped =
        HtmlEscape.escapeHtml(
             text,
             HtmlEscapeType.HTML4_NAMED_REFERENCES_DEFAULT_TO_HEXA,
             HtmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT);
Unescaping

Some sample code (see the javadoc for more detail):

final String unescaped = HtmlEscape.unescapeHtml(text);

XML

Escape/unescape utility class: org.unbescape.xml.XmlEscape

Configuration
  • Escape Types: org.unbescape.xml.XmlEscapeType
    • CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_DECIMAL
    • CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
    • DECIMAL_REFERENCES
    • HEXADECIMAL_REFERENCES
  • Escape Levels: org.unbescape.xml.XmlEscapeLevel
    • LEVEL_1_ONLY_MARKUP_SIGNIFICANT
    • LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
    • LEVEL_3_ALL_NON_ALPHANUMERIC
    • LEVEL_4_ALL_CHARACTERS
Escaping

Some sample code (see the javadoc for more detail):

final String escaped = XmlEscape.escapeXml11(text);
final String escaped = XmlEscape.escapeXml10Minimal(text);
final String escaped =
        XmlEscape.escapeXml11(
             text,
             XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_DECIMAL,
             XmlEscapeLevel.LEVEL_3_ALL_NON_ALPHANUMERIC);
Unescaping

Some sample code (see the javadoc for more detail):

final String unescaped = XmlEscape.unescapeXml(text);

JavaScript

Escape/unescape utility class: org.unbescape.javascript.JavaScriptEscape

Configuration
  • Escape Types: org.unbescape.javascript.JavaScriptEscapeType
    • SINGLE_ESCAPE_CHARS_DEFAULT_TO_XHEXA_AND_UHEXA
    • SINGLE_ESCAPE_CHARS_DEFAULT_TO_UHEXA
    • XHEXA_DEFAULT_TO_UHEXA
    • UHEXA
  • Escape Levels: org.unbescape.javascript.JavaScriptEscapeLevel
    • LEVEL_1_BASIC_ESCAPE_SET
    • LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET
    • LEVEL_3_ALL_NON_ALPHANUMERIC
    • LEVEL_4_ALL_CHARACTERS
Escaping

Some sample code (see the javadoc for more detail):

final String escaped = JavaScriptEscape.escapeJavaScript(text);
final String escaped =
        JavaScriptEscape.escapeJavaScript(
             text,
             JavaScriptEscapeType.SINGLE_ESCAPE_CHARS_DEFAULT_TO_XHEXA_AND_UHEXA,
             JavaScriptEscapeLevel.LEVEL_1_BASIC_ESCAPE_SET);
Unescaping

Some sample code (see the javadoc for more detail):

final String unescaped = JavaScriptEscape.unescapeJavaScript(text);

JSON

Escape/unescape utility class: org.unbescape.json.JsonEscape

Configuration
  • Escape Types: org.json.javascript.JsonEscapeType
    • SINGLE_ESCAPE_CHARS_DEFAULT_TO_UHEXA
    • UHEXA
  • Escape Levels: org.json.javascript.JsonEscapeLevel
    • LEVEL_1_BASIC_ESCAPE_SET
    • LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET
    • LEVEL_3_ALL_NON_ALPHANUMERIC
    • LEVEL_4_ALL_CHARACTERS
Escaping

Some sample code (see the javadoc for more detail):

final String escaped = JsonEscape.escapeJson(text);
final String escaped =
        JsonEscape.escapeJson(
             text,
             JsonEscapeType.SINGLE_ESCAPE_CHARS_DEFAULT_TO__UHEXA,
             JsonEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
Unescaping

Some sample code (see the javadoc for more detail):

final String unescaped = JsonEscape.unescapeJson(text);

URI/URL

Escape/unescape utility class: org.unbescape.uri.UriEscape

Escaping

Some sample code (see the javadoc for more detail):

final String escapedPath = UriEscape.escapeUriPath(text);
final String escapedPathSegment = UriEscape.escapeUriPathSegment(text);
final String escapedQueryParam = UriEscape.escapeUriQueryParam(text);
final String escapedFragmentId = UriEscape.escapeUriFragmentId(text);
Unescaping

Some sample code (see the javadoc for more detail):

final String unescapedPath = UriEscape.unescapeUriPath(text);
final String unescapedPathSegment = UriEscape.unescapeUriPathSegment(text);
final String unescapedQueryParam = UriEscape.unescapeUriQueryParam(text);
final String unescapedFragmentId = UriEscape.unescapeUriFragmentId(text);

CSS

Escape/unescape utility class: org.unbescape.css.CssEscape

Configuration
  • Escape Types: org.unbescape.css.CssIdentifierEscapeType / org.unbescape.css.CssStringEscapeType
    • BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA
    • BACKSLASH_ESCAPES_DEFAULT_TO_SIX_DIGIT_HEXA
    • COMPACT_HEXA
    • SIX_DIGIT_HEXA
  • Escape Levels: org.unbescape.css.CssIdentifierEscapeLevel / org.unbescape.css.CssStringEscapeLevel
    • LEVEL_1_BASIC_ESCAPE_SET
    • LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET
    • LEVEL_3_ALL_NON_ALPHANUMERIC
    • LEVEL_4_ALL_CHARACTERS
Escaping

Some sample code (see the javadoc for more detail):

final String escapedIdentifier = CssEscape.escapeCssIdentifier(text);
final String escapedString = CssEscape.escapeCssString(text);
final String escapedIdentifier =
        CssEscape.escapeCssIdentifier(
             text,
             CssIdentifierEscapeType.BACKSLASH_ESCAPES_DEFAULT_TO_SIX_DIGIT_HEXA,
             CssIdentifierEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
final String escapedString =
        CssEscape.escapeCssString(
             text,
             CssStringEscapeType.BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA,
             CssStringEscapeLevel.LEVEL_1_BASIC_ESCAPE_SET);
Unescaping

Some sample code (see the javadoc for more detail):

final String unescaped = CssEscape.unescapeCss(escapedIdentifierOrString);

CSV (Comma-Separated Values)

Escape/unescape utility class: org.unbescape.csv.CsvEscape

Escaping

Some sample code (see the javadoc for more detail):

final String escaped = CsvEscape.escapeCsv(text);
Unescaping

Some sample code (see the javadoc for more detail):

final String unescaped = CsvEscape.unescapeCsv(text);

Java literals

Escape/unescape utility class: org.unbescape.java.JavaEscape

Configuration
  • Escape Levels: org.unbescape.java.JavaEscapeLevel
    • LEVEL_1_BASIC_ESCAPE_SET
    • LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET
    • LEVEL_3_ALL_NON_ALPHANUMERIC
    • LEVEL_4_ALL_CHARACTERS
Escaping

Some sample code (see the javadoc for more detail):

final String escaped = JavaEscape.escapeJava(text);
final String escaped =
        JavaEscape.escapeJava(
             text,
             JavaEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
Unescaping

Some sample code (see the javadoc for more detail):

final String unescaped = JavaEscape.unescapeJava(escaped);

Java .properties files

Escape/unescape utility class: org.unbescape.properties.PropertiesEscape

Configuration
  • Escape Levels: org.unbescape.properties.PropertiesKeyEscapeLevel / org.unbescape.properties.PropertiesValueEscapeLevel
    • LEVEL_1_BASIC_ESCAPE_SET
    • LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET
    • LEVEL_3_ALL_NON_ALPHANUMERIC
    • LEVEL_4_ALL_CHARACTERS
Escaping

Some sample code (see the javadoc for more detail):

final String escapedKey = PropertiesEscape.escapePropertiesKey(text);
final String escapedString = PropertiesEscape.escapePropertiesValue(text);
final String escapedKey =
        PropertiesEscape.escapePropertiesKey(
             keyText, PropertiesKeyEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
final String escapedValue =
        PropertiesEscape.escapePropertiesValue(
             valueText, PropertiesValueEscapeLevel.LEVEL_1_BASIC_ESCAPE_SET);
Unescaping

Some sample code (see the javadoc for more detail):

final String unescaped = PropertiesEscape.unescapeProperties(escapedKeyOrValue);