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

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 source)
Returns the provided string where all HTML special characters (e.g.
StringBuilder sb = new StringBuilder(source.length());
int start = -1, end = -1;
int last = 0;
start = source.indexOf("&");
end = source.indexOf(";", start);
while (start > -1 && end > start) {
    String encoded = source.substring(start, end + 1);
    String decoded = HTML_CODES.get(encoded);
...
StringunescapeHTML(String source)
unescape HTML
int i, j;
boolean continueLoop;
int skip = 0;
do {
    continueLoop = false;
    i = source.indexOf("&", skip);
    if (i > -1) {
        j = source.indexOf(";", i);
...
StringunescapeHTML(String source, int start)
unescape HTML
int i, j;
i = source.indexOf("&", start);
while (i > -1) {
    j = source.indexOf(";", i);
    if (j > i) {
        String entityToLookFor = source.substring(i, j + 1);
        String value = htmlEntities.get(entityToLookFor);
        if (value != null) {
...
StringunescapeHTML(String str)
escapes the 5 special html chars - see http://www.w3schools.com/tags/ref_entities.asp
if (str == null)
    return null;
str = str.replace("&amp;", "&");
str = str.replace("&apos;", "'");
str = str.replace("&quot;", "\"");
str = str.replace("&lt;", "<");
str = str.replace("&gt;", ">");
str = str.replace("\u0095", "."); 
...
StringunEscapeHtml(String text)
Unescapes a string containing entity escapes to a string containing the actual Unicode characters corresponding to the escapes.
if (text == null || text.length() == 0) {
    return "";
String result = text;
result = result.replace("&lt;", "<");
result = result.replace("&gt;", ">");
result = result.replace("&amp;", "&");
result = result.replace("&quot;", "\"");
...
StringunescapeHTML(String value)
unescape HTML
if (value == null)
    return null;
if (value.indexOf('&') < 0)
    return value;
Map<String, Character> ent = getHtmlEntities();
StringBuffer sb = new StringBuffer();
final int length = value.length();
for (int i = 0; i < length; i++) {
...
StringunescapeHTML(String value)
unescape HTML
return replaceStrings(value, specialHtmlEscapes, specialHtmlChars);
StringunescapeHTML2(String source, int start)
unescape HTML
int i, j;
i = source.indexOf("&", start);
if (i > -1) {
    j = source.indexOf(";", i);
    if (j > i) {
        String entityToLookFor = source.substring(i, j + 1);
        String value = htmlEntities.get(entityToLookFor);
        if (value != null) {
...
StringunescapeHtmlByName(final String input)
Unescapes HTML characters based on it name (value).
String result = input;
for (int i = 0; i < BASIC_HTML_ESCAPE.length; i++) {
    result = replace(result, BASIC_HTML_ESCAPE[i][1], BASIC_HTML_ESCAPE[i][0]);
return result;