public final class CharEscapers extends Object
Modifier and Type | Method and Description |
---|---|
static String |
decodeUri(String uri)
Decodes application/x-www-form-urlencoded strings.
|
static String |
decodeUriPath(String path)
Decodes the path component of a URI.
|
static String |
escapeUri(String value)
Deprecated.
|
static String |
escapeUriConformant(String value)
Escapes the string value so it can be safely included in any part of a URI.
|
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.
|
@Deprecated 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 escapeUriConformant(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 decodeUri(String uri)
This replaces each occurrence of '+' with a space, ' '. 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 decodeUriPath(String path)
URLDecoder.decode(String, String)
). This
method transforms URI encoded values into their decoded symbols.
e.g. decodePath("%3Co%3E")
returns "<o>"
path
- the value to be decodedpath
public 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 does not escape '?', '+', and '/'.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–2020 Google. All rights reserved.