public abstract class HtmlUtils extends Object
| 构造器和说明 |
|---|
HtmlUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
htmlEscape(String input)
Turn special characters into HTML character references.
|
static String |
htmlEscape(String input,
String encoding)
Turn special characters into HTML character references.
|
static String |
htmlEscapeDecimal(String input)
Turn special characters into HTML character references.
|
static String |
htmlEscapeDecimal(String input,
String encoding)
Turn special characters into HTML character references.
|
static String |
htmlEscapeHex(String input)
Turn special characters into HTML character references.
|
static String |
htmlEscapeHex(String input,
String encoding)
Turn special characters into HTML character references.
|
static String |
htmlUnescape(String input)
Turn HTML character references into their plain text UNICODE equivalent.
|
public static String htmlEscape(String input)
Handles complete character set defined in HTML 4.01 recommendation.
Escapes all special characters to their corresponding
entity reference (e.g. <).
input - the (unescaped) input stringpublic static String htmlEscape(String input, String encoding)
Handles complete character set defined in HTML 4.01 recommendation.
Escapes all special characters to their corresponding
entity reference (e.g. <) at least as required by the
specified encoding. In other words, if a special character does
not have to be escaped for the given encoding, it may not be.
input - the (unescaped) input stringencoding - the name of a supported charsetpublic static String htmlEscapeDecimal(String input)
Handles complete character set defined in HTML 4.01 recommendation.
Escapes all special characters to their corresponding numeric reference in decimal format
input - the (unescaped) input stringpublic static String htmlEscapeDecimal(String input, String encoding)
Handles complete character set defined in HTML 4.01 recommendation.
Escapes all special characters to their corresponding numeric reference in decimal format at least as required by the specified encoding. In other words, if a special character does not have to be escaped for the given encoding, it may not be.
input - the (unescaped) input stringencoding - the name of a supported charsetpublic static String htmlEscapeHex(String input)
Handles complete character set defined in HTML 4.01 recommendation.
Escapes all special characters to their corresponding numeric reference in hex format
input - the (unescaped) input stringpublic static String htmlEscapeHex(String input, String encoding)
Handles complete character set defined in HTML 4.01 recommendation.
Escapes all special characters to their corresponding numeric reference in hex format at least as required by the specified encoding. In other words, if a special character does not have to be escaped for the given encoding, it may not be.
input - the (unescaped) input stringencoding - the name of a supported charsetpublic static String htmlUnescape(String input)
Handles complete character set defined in HTML 4.01 recommendation and all reference types (decimal, hex, and entity).
Correctly converts the following formats:
&#Entity; - (Example: &) case sensitive &#Decimal; - (Example: D)
&#xHex; - (Example: å) case insensitive
Gracefully handles malformed character references by copying original characters as is when encountered.
input - the (escaped) input stringCopyright © 2024. All rights reserved.