public final class CharEscapers
extends java.lang.Object
CharEscaper
s, and some commonly used
CharEscaper
instances.Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decodeUri(java.lang.String uri)
Percent-decodes a US-ASCII string into a Unicode string.
|
static java.lang.String |
escapeUri(java.lang.String value)
Escapes the string value so it can be safely included in URIs.
|
static java.lang.String |
escapeUriPath(java.lang.String value)
Escapes the string value so it can be safely included in URI path segments.
|
static java.lang.String |
escapeUriPathWithoutReserved(java.lang.String value)
Escapes a URI path but retains all reserved characters, including all general delimiters.
|
static java.lang.String |
escapeUriQuery(java.lang.String value)
Escapes the string value so it can be safely included in URI query string segments.
|
static java.lang.String |
escapeUriUserInfo(java.lang.String value)
Escapes the string value so it can be safely included in URI user info part.
|
public static java.lang.String escapeUri(java.lang.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 java.lang.String decodeUri(java.lang.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 stringpublic static java.lang.String escapeUriPath(java.lang.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 java.lang.String escapeUriPathWithoutReserved(java.lang.String value)
escapeUriPath(String)
except that it keeps '?', '+', and '/'
unescaped.public static java.lang.String escapeUriUserInfo(java.lang.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 java.lang.String escapeUriQuery(java.lang.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."
Copyright © 2011-2018 Google. All Rights Reserved.