Package com.iizix.text
Class HTMLUtilities
- java.lang.Object
- com.iizix.text.HTMLUtilities
public class HTMLUtilities extends java.lang.Object
Utility routines for HTML text.- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description HTMLUtilities()
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
escapeCharsCodes(java.lang.String string)
Escapes all characters in the string that are below 32 (space) or above or equal to 127 to a "&#nnn;".static java.lang.String
escapeString(java.lang.String string, boolean doLineBreaks)
Escapes a string as the rules for quoted value for HTML.static java.lang.String
escapeTagValueString(java.lang.String string)
Escapes a string as the rules for quoted value in HTML tag specifies.static java.lang.String
replaceCharacterEntities(java.lang.String string)
Replaces all strings such as © � &x0000; to character values.
Method Detail
escapeString
public static java.lang.String escapeString(java.lang.String string, boolean doLineBreaks)
Escapes a string as the rules for quoted value for HTML.The following rules apply:
- Single CR, Single LF, CR/LF or LF/CR is replaced with '<br>'.
- White space characters (Tab, VT, FF) are left as is.
- '&' is replaced by '&'
- '<' and '>' are replaced with '<' and '>'
- " is replaced by "
- All control characters (below space/0x20/32) are replaced by &#nnn;, & to &, double-quote to ", < to < and > to >.
- Parameters:
string
- The input string.doLineBreaks
- Flag to replace CR/LF combinations with '<br>' when true, false not to replace and leave as is.- Returns:
- The escaped string, to surround with double-quotes when passed as a HTML value parameter in a tag.
escapeTagValueString
public static java.lang.String escapeTagValueString(java.lang.String string)
Escapes a string as the rules for quoted value in HTML tag specifies.- White space characters (Tab, CR, LF, VT, FF) are left as is.
- '&' is replaced by '&'
- '<' and '>' are replaced with '<' and '>'
- " is replaced by "
- All control characters (below space/0x20/32) are replaced by &#nnn;, & to &, double-quote to ", < to < and > to >.
- Parameters:
string
- The input string.- Returns:
- The escaped string, to surround with double-quotes when passed as a HTML value parameter in a tag.
escapeCharsCodes
public static java.lang.String escapeCharsCodes(java.lang.String string)
Escapes all characters in the string that are below 32 (space) or above or equal to 127 to a "&#nnn;".- Parameters:
string
- The input string.- Returns:
- The escaped string.
replaceCharacterEntities
public static java.lang.String replaceCharacterEntities(java.lang.String string)
Replaces all strings such as © � &x0000; to character values.- Parameters:
string
- Input string.- Returns:
- The "decoded" string (kind of inverted encode function).