public final class CharEscapers extends Object
CharEscapers, and some commonly used
CharEscaper instances.
| Modifier and Type | Method and Description |
|---|---|
static String |
decodeUri(String
Percent-decodes a US-ASCII string into a Unicode string.
|
static String |
escapeUri(String
Escapes the string value so it can be safely included in URIs.
|
static String |
escapeUriPath(String
Escapes the string value so it can be safely included in URI path segments.
|
static String |
escapeUriPathWithoutReserved(String
Escapes a URI path but retains all reserved characters, including all general delimiters.
|
static String |
escapeUriQuery(String
Escapes the string value so it can be safely included in URI query string segments.
|
static String |
escapeUriUserInfo(String
Escapes the string value so it can be safely included in URI user info part.
|
public static StringescapeUri(String value)
When encoding a String, the following rules apply:
Note: Unlike other escapers, URI escapers produce uppercase hexadecimal sequences. From RFC 3986:
"URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings."
This escaper has identical behavior to (but is potentially much faster than):
URLEncoder.encode(String, String) with the encoding name "UTF-8" public static StringdecodeUri(String uri)
This replaces each occurrence of '+' with a space, ' '. So this method should not be used for non application/x-www-form-urlencoded strings such as host and path.
uri - a percent-encoded US-ASCII string
public static StringescapeUriPath(String value)
When encoding a String, the following rules apply:
Note: Unlike other escapers, URI escapers produce uppercase hexadecimal sequences. From RFC 3986:
"URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings."
public static StringescapeUriPathWithoutReserved(String value)
escapeUriPath(String) except that it keeps '?', '+', and '/' unescaped.
public static StringescapeUriUserInfo(String value)
When encoding a String, the following rules apply:
Note: Unlike other escapers, URI escapers produce uppercase hexadecimal sequences. From RFC 3986:
"URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings."
public static StringescapeUriQuery(String value)
This escaper is also suitable for escaping fragment identifiers.
For details on escaping URIs, see RFC 3986 - section 2.4.
When encoding a String, the following rules apply:
Note: Unlike other escapers, URI escapers produce uppercase hexadecimal sequences. From RFC 3986:
"URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings."