Possible Duplicate:
Java: How to decode HTML character entities in Java like HttpUtility.HtmlDecode?
is there a Java/Android way to convert HTML-escaped strings (such as Ö
or ß
) back to their ASCII/Unicode representations (such as Ö
or ß
)?
I of course do not want to do a simple string-replacement and try with just every HTML-escape-sequence that exists, I'd guess there is a ready-to use solution?
Thanks!
Use this:
import org.apache.commons.lang.StringEscapeUtils;
public class StringEscapeUtilsTrial {
public static void main(String[] args) {
String strHTMLInput = "<p>MyName<p>";
String strEscapeHTML = StringEscapeUtils.escapeHtml(strHTMLInput);
String strUnEscapeHTML = StringEscapeUtils.unescapeHtml(strEscapeHTML);
System.out.println("Escaped HTML >>> " + strEscapeHTML);
System.out.println("UnEscaped HTML >>> " + strUnEscapeHTML);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With