List of usage examples for org.springframework.web.util HtmlCharacterEntityDecoder HtmlCharacterEntityDecoder
public HtmlCharacterEntityDecoder(HtmlCharacterEntityReferences characterEntityReferences, String original)
From source file:org.springframework.web.util.HtmlUtils.java
/** * Turn HTML character references into their plain text UNICODE equivalent. * <p>Handles complete character set defined in HTML 4.01 recommendation * and all reference types (decimal, hex, and entity). * <p>Correctly converts the following formats: * <blockquote>/*from ww w . ja v a 2 s .co m*/ * &#<i>Entity</i>; - <i>(Example: &amp;) case sensitive</i> * &#<i>Decimal</i>; - <i>(Example: &#68;)</i><br> * &#x<i>Hex</i>; - <i>(Example: &#xE5;) case insensitive</i><br> * </blockquote> * Gracefully handles malformed character references by copying original * characters as is when encountered.<p> * <p>Reference: * <a href="http://www.w3.org/TR/html4/sgml/entities.html"> * http://www.w3.org/TR/html4/sgml/entities.html * </a> * @param input the (escaped) input string * @return the unescaped string */ public static String htmlUnescape(String input) { if (input == null) { return null; } return new HtmlCharacterEntityDecoder(characterEntityReferences, input).decode(); }