public class CustomURLEncoder
extends java.lang.Object
String
into a MIME format called
"x-www-form-urlencoded
" format.
To convert a String
, each character is examined in turn:
a
' through 'z
',
'A
' through 'Z
', '0
'
through '9
', and ".", "-",
"*", "_" remain the same.
' is converted into a
plus sign '+
'.
%xy
", where xy is the two-digit
hexadecimal representation of the lower 8-bits of the character.
Modifier and Type | Field and Description |
---|---|
static int |
kPlatformMac |
static int |
kPlatformUnix |
static int |
kPlatformWindows |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decode(java.lang.String s)
Deprecated.
|
static java.lang.String |
decodeFragment(java.lang.String s)
Apply decoding rules for an URL's query part.
|
static java.lang.String |
decodePathSegment(java.lang.String s)
Apply decoding rules for an URL's path segment.
|
static java.lang.String |
decodeQuery(java.lang.String s)
Apply decoding rules for an URL's query part.
|
static java.lang.String |
encode(java.lang.String s)
Deprecated.
|
static java.lang.String |
encodeFragment(java.lang.String s)
Apply encoding rules for an URL's query part.
|
static java.lang.String |
encodePathSegment(java.lang.String s)
Apply encoding rules for an URL's path segement.
|
static java.lang.String |
encodeQuery(java.lang.String s)
Apply encoding rules for an URL's query part.
|
public static final int kPlatformWindows
public static final int kPlatformMac
public static final int kPlatformUnix
@Deprecated public static java.lang.String encode(java.lang.String s)
x-www-form-urlencoded
format.s
- String
to be translated.String
.@Deprecated public static java.lang.String decode(java.lang.String s)
x-www-form-urlencoded
format to a UTF-8 Java string.
2005-10-14: Added new heuristics: What to do when the string contains high-ASCII-characters? E.g. Word writes
"URL"s that have spaces quoted correctly (%20), but have umlauts simply written 1:1 as high-ASCII characters.
What we need to do is determine which encoding we should use for that hi-ASCII characters to convert it into the
appropriate Unicode character. For now, we assume that any hi-ASCII-characters are UTF-8 compatible, i.e.
part of CP1252s
- String
to be decoded.String
.public static java.lang.String encodeQuery(java.lang.String s)
s
- public static java.lang.String decodeQuery(java.lang.String s)
s
- public static java.lang.String encodeFragment(java.lang.String s)
s
- public static java.lang.String decodeFragment(java.lang.String s)
s
- public static java.lang.String encodePathSegment(java.lang.String s)
s
- public static java.lang.String decodePathSegment(java.lang.String s)
s
-