Java Utililty Methods HTML Unescape

List of utility methods to do HTML Unescape

Description

The list of methods to do HTML Unescape are organized into topic(s).

Method

StringhtmlUnescape(String s)
Turn HTML character references into their plain text UNICODE equivalent.
if (s == null) {
    return null;
StringBuffer unescaped = new StringBuffer(s.length());
for (int i = 0; i < s.length(); i++) {
    char c = s.charAt(i);
    if (c == '&') {
        int start = Math.min(i + 1, s.length() - 1);
...
StringhtmlUnescape(String source)
Reverses htmlEscape.
StringBuffer buf = new StringBuffer();
if (source != null) {
    for (int i = 0; i < source.length(); ++i) {
        char ch = source.charAt(i);
        if (ch == '&') {
            int semi = source.indexOf(';', i + 1);
            if (semi == -1) {
                buf.append(ch);
...
StringunEscapeHTML(final String escapedHTML)
Replace HTML escape sequences with the correct characters
String retVal = escapedHTML;
retVal = retVal.replaceAll("&gt;", ">");
retVal = retVal.replaceAll("&lt;", "<");
retVal = retVal.replaceAll("&amp;", "&");
retVal = retVal.replaceAll("&nbsp;", " ");
return retVal;
StringunescapeHtml(final String input)
Unescapes HTML characters from the input.
String unescapeHexHtmlOutput = unescapeHtmlByNumber(input);
return unescapeHtmlByName(unescapeHexHtmlOutput);
StringunescapeHTML(String comment)
unescape HTML
int length = comment.length();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < length; ++i) {
    String comp = comment.substring(i, i + 1);
    if (" ".compareTo(comp) == 0) {
        comp = comment.substring(++i, i + 1);
        buffer.append("&nbsp");
    } else if ("\r".compareTo(comp) == 0) {
...
StringunescapeHTML(String html)
Given escaped html characters, unescapes them.
return html.replace("&apos;", "'").replace("&quot;", "\"").replace("&gt;", ">").replace("&lt;", "<")
        .replace("&amp;", "&");
StringunescapeHtml(String s)
unescape Html
if (s == null || s.indexOf('&') == -1)
    return s;
s = s.replace("&lt;", "<");
s = s.replace("&gt;", ">");
s = s.replace("&quot;", "\"");
s = s.replace("&#39;", "'");
s = s.replace("&amp;", "&");
return s;
...
StringunescapeHTML(String s)
Turn any HTML escape entities in the string into characters and return the resulting string.
StringBuffer result = new StringBuffer(s.length());
int ampInd = s.indexOf("&");
int lastEnd = 0;
while (ampInd >= 0) {
    int nextAmp = s.indexOf("&", ampInd + 1);
    int nextSemi = s.indexOf(";", ampInd + 1);
    if (nextSemi != -1 && (nextAmp == -1 || nextSemi < nextAmp)) {
        int value = -1;
...
StringunescapeHtml(String s)
Reverses the escaping done by escapeForHtml.
final int sLength = s.length();
final StringBuilder result = new StringBuilder(sLength);
for (int i = 0; i < sLength; ++i) {
    final char ch = s.charAt(i);
    if (ch == '&') {
        if (s.startsWith("&amp;", i)) {
            result.append('&');
            i += 4;
...
StringunescapeHTML(String s)
unescape HTML
String[][] escape = { { "&lt;", "<" }, { "&gt;", ">" }, { "&amp;", "&" }, { "&quot;", "\"" },
        { "&agrave;", "\u00e0" }, { "&Agrave;", "\u00c0" }, { "&acirc;", "\u00e2" }, { "&auml;", "\u00e4" },
        { "&Auml;", "\u00c4" }, { "&Acirc;", "\u00c2" }, { "&aring;", "\u00e5" }, { "&Aring;", "\u00c5" },
        { "&aelig;", "\u00e6" }, { "&AElig;", "\u00c6" }, { "&ccedil;", "\u00e7" },
        { "&Ccedil;", "\u00c7" }, { "&eacute;", "\u00e9" }, { "&Eacute;", "\u00c9" },
        { "&egrave;", "\u00e8" }, { "&Egrave;", "\u00c8" }, { "&ecirc;", "\u00ea" },
        { "&Ecirc;", "\u00ca" }, { "&euml;", "\u00eb" }, { "&Euml;", "\u00cb" }, { "&iuml;", "\u00ef" },
        { "&Iuml;", "\u00cf" }, { "&ocirc;", "\u00f4" }, { "&Ocirc;", "\u00d4" }, { "&ouml;", "\u00f6" },
...