org.keel.util.string
Class URLUTF8Encoder
java.lang.Object
org.keel.util.string.URLUTF8Encoder
- public class URLUTF8Encoder
- extends java.lang.Object
Class to encode a string into a form suitable for inclusion in a URL, via the UTF-8 algorithm
| Field Summary |
(package private) static java.lang.String[] |
hex
|
| Method Summary |
static java.lang.String |
decode(java.lang.String s)
Decode a UTF-8 encoded-string, returning the original string. |
static java.lang.String |
encode(java.lang.String s)
Encode a string to the "x-www-form-urlencoded" form, enhanced with the UTF-8-in-URL proposal. |
static void |
main(java.lang.String[] args)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
hex
static final java.lang.String[] hex
-
URLUTF8Encoder
private URLUTF8Encoder()
encode
public static java.lang.String encode(java.lang.String s)
-
Encode a string to the "x-www-form-urlencoded" form, enhanced with the UTF-8-in-URL proposal. This is what happens:
-
The ASCII characters 'a' through 'z', 'A' through 'Z', and '0' through '9' remain the same.
-
The space character ' ' is converted into a plus sign '+'.
-
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".
-
- Parameters:
s - The string to be encoded
- Returns:
- The encoded string
decode
public static java.lang.String decode(java.lang.String s)
-
Decode a UTF-8 encoded-string, returning the original string.
-
- Parameters:
s - The encoded string
- Returns:
- The decoded string
main
public static void main(java.lang.String[] args)
-
Please see keelframework.org for information about new Keel releases.