public final class UrlDecoder extends Object
UrlEncoder
.
In contrast to the URLDecoder
, this class therefore does not decode
'+' (plus) into ' ' (space)!
Additionally, this class does not use the default encoding, but always UTF-8, if not specified otherwise.
The reason for this class is that File.toURI()
does not encode a "+" sign. Therefore, our URL-encoding and decoding must
not handle the "+" specifically.
Another reason is JERSEY-417.
I originally used org.glassfish.jersey.uri.UriComponent.encode(String, Type)
at some code locations, but since not all code locations have a dependency on Jersey,
I decided to switch consistently everywhere to UrlEncoder
and UrlDecoder
.
This class was copied from URLDecoder
and changed to fit our needs.
UrlEncoder
Modifier and Type | Method and Description |
---|---|
static String |
decode(String s)
Decodes a
application/x-www-form-urlencoded string using UTF-8. |
static String |
decode(String s,
Charset charset)
Deprecated.
UTF-8 should be used; it is thus recommended to invoke
decode(String) instead. |
static String |
decode(String s,
String enc)
Deprecated.
UTF-8 should be used; it is thus recommended to invoke
decode(String) instead. |
public static String decode(String s)
application/x-www-form-urlencoded
string using UTF-8.s
- the String
to decodeString
UrlEncoder.encode(String)
@Deprecated public static String decode(String s, String enc) throws UnsupportedEncodingException
decode(String)
instead.application/x-www-form-urlencoded
string using a specific
encoding scheme.
The supplied encoding is used to determine
what characters are represented by any consecutive sequences of the
form "%xy
".
Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.
s
- the String
to decodeenc
- The name of a supported
character
encoding.String
UnsupportedEncodingException
- If character encoding needs to be consulted, but
named character encoding is not supportedUrlEncoder.encode(String, String)
@Deprecated public static String decode(String s, Charset charset)
decode(String)
instead.application/x-www-form-urlencoded
string using a specific
encoding scheme.
The supplied encoding is used to determine
what characters are represented by any consecutive sequences of the
form "%xy
".
Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.
s
- the String
to decodecharset
- The character encoding.String
UnsupportedEncodingException
- If character encoding needs to be consulted, but
named character encoding is not supportedUrlEncoder.encode(String, Charset)
Copyright © 2013–2019. All rights reserved.