public class UTFEncodingUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decode(java.lang.String s,
java.lang.String encoding) |
static java.lang.String |
decodeUTF(java.lang.String s) |
static java.lang.String |
encode(java.lang.String s) |
static java.lang.String |
encode(java.lang.String s,
java.lang.String encoding) |
static java.lang.String |
encodeUTF8(java.lang.String s)
Encode a string according to RFC 1738.
|
public static java.lang.String encodeUTF8(java.lang.String s)
"...Only alphanumerics [0-9a-zA-Z], the special characters "$-_.+!*'()," [not including the quotes - ed], and reserved characters used for their reserved purposes may be used unencoded within a URL."
The ASCII characters 'a' through 'z', 'A' through 'Z', and '0' through '9' remain the same.
The unreserved characters - _ . ! ~ * ' ( ) remain the same.
All other ASCII characters are converted into the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the character code
All non-ASCII characters are encoded in two steps: first to a sequence of 2 or 3 bytes, using the UTF-8 algorithm; secondly each of these bytes is encoded as "%xx".
s
- The string to be encodedpublic static java.lang.String encode(java.lang.String s, java.lang.String encoding) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public static java.lang.String encode(java.lang.String s) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public static java.lang.String decode(java.lang.String s, java.lang.String encoding) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public static java.lang.String decodeUTF(java.lang.String s)