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