unbescape 是一个 Java 的转义库,特点是高性能和易用,而且功能强大,支持多种格式的转义,包括:
HTML (HTML5 and HTML 4)
XML (XML 1.0 and XML 1.1)
JavaScript
JSON
URI / URL (both paths and query parameters)
CSS (both identifiers and string literals)
CSV (Comma-Separated Values)
Java literals
Java.properties files (both keys and values)
.properties
示例代码:
final String escaped = HtmlEscape.escapeHtml( text, HtmlEscapeType.HTML4_NAMED_REFERENCES_DEFAULT_TO_HEXA, HtmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT);