org.springframework.web.util
Class HtmlUtils

java.lang.Object
  extended byorg.springframework.web.util.HtmlUtils

public abstract class HtmlUtils
extends Object

Utility class for HTML escaping. Escapes and unescapes based on the W3C HTML 4.01 recommendation.

Reference: http://www.w3.org/TR/html4/charset.html

Since:
01.03.2003
Author:
Chris Wilson, Juergen Hoeller

Constructor Summary
HtmlUtils()
           
 
Method Summary
static String htmlEscape(String input)
          Turn special characters into HTML character references.
static String htmlUnescape(String input)
          Turn HTML character references into their plain text UNICODE equivalent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlUtils

public HtmlUtils()
Method Detail

htmlEscape

public static String htmlEscape(String input)
Turn special characters into HTML character references. Handles complete character set defined in HTML 4.01 recommendation.

Escapes all special characters to their corresponding numerial reference in the decimal format: &#Decimal;

Reference: http://www.w3.org/TR/html4/sgml/entities.html

Parameters:
input - the (unescaped) input string
Returns:
the escaped string

htmlUnescape

public static String htmlUnescape(String input)
Turn HTML character references into their plain text UNICODE equivalent.

Handles complete character set defined in HTML 4.01 recommendation and all reference types (decimal, hex, and entity).

Correctly converts the following formats:

&#Decimal; - (Example: D)
&#xHex; - (Example: å) case insensitive
&#Entity; - (Example: &) case sensitive
Gracefully handles malformed character references by copying original characters as is when encountered.

Reference: http://www.w3.org/TR/html4/sgml/entities.html

Parameters:
input - the (escaped) input string
Returns:
the unescaped string


Copyright (C) 2003-2004 The Spring Framework Project.