Class CompatURLEncoder

java.lang.Object
  |
  +--CompatURLEncoder

public class CompatURLEncoder
extends java.lang.Object

This utility class contains static methods that converts a string into a fully encoded URL string in x-www-form-urlencoded format. This format replaces certain disallowed characters with encoded equivalents. All upper case and lower case letters in the US alphabet remain as is, the space character (' ') is replaced with '+' sign, and all other characters are converted to a "%XX" format where XX is the hexadecimal representation of that character in a certain encoding (by default "UTF-8").

This method is very useful for encoding strings to be sent to CGI scripts

Author:
Aaron M. Renn (arenn@urbanophile.com), Warren Levy , Mark Wielaard (mark@klomp.org)

Method Summary
static java.lang.String encode(java.lang.String s)
          Deprecated.  
static java.lang.String encode(java.lang.String s, java.lang.String encoding)
          This method translates the passed in string into x-www-form-urlencoded format using the character encoding to hex-encode the unsafe characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public static java.lang.String encode(java.lang.String s)
Deprecated.  

This method translates the passed in string into x-www-form-urlencoded format using the standard "UTF-8" character encoding to hex-encode the unsafe characters.
Parameters:
s - The String to convert
Returns:
The converted String

encode

public static java.lang.String encode(java.lang.String s,
                                      java.lang.String encoding)
                               throws java.io.UnsupportedEncodingException
This method translates the passed in string into x-www-form-urlencoded format using the character encoding to hex-encode the unsafe characters.
Parameters:
s - The String to convert
encoding - The encoding to use for unsafe characters
Returns:
The converted String
Throws:
java.io.UnsupportedEncodingException - If the named encoding is not supported
Since:
1.4