Java HTML Unescape unescapeHTML(String source)

Here you can find the source of unescapeHTML(String source)

Description

unescape HTML

License

Open Source License

Declaration

public static final String unescapeHTML(String source) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.HashMap;

public class Main {
    private static HashMap<String, String> htmlEntities;

    public static final String unescapeHTML(String source) {
        int i, j;

        boolean continueLoop;
        int skip = 0;
        do {//from ww  w  .  j  av a2  s .co  m
            continueLoop = false;
            i = source.indexOf("&", skip);
            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) {
                        source = source.substring(0, i) + value + source.substring(j + 1);
                        continueLoop = true;
                    } else {
                        skip = i + 1;
                        continueLoop = true;
                    }
                }
            }
        } while (continueLoop);
        return source;
    }
}

Related

  1. unescapeHTML(String s)
  2. unescapeHtml(String s)
  3. unescapeHTML(String s)
  4. unescapeHTML(String s)
  5. unescapeHTML(String source)
  6. unescapeHTML(String source, int start)
  7. unescapeHTML(String str)
  8. unEscapeHtml(String text)
  9. unescapeHTML(String value)