|  | Posted by Harlan Messinger on 12/20/07 16:32 
David Segall wrote:> I want to encode a string that will be used as a GET data parameter
 > but the algorithm I have can produce the characters "/", "+" and "="
 > in addition to alphanumeric characters. Those characters don't have a
 > named entity in my HTML text book so I believe they can be used
 > without further encoding. Can they? In other words, is the URL
 > <http://example.com?myparam=four/two+3=5> valid? For extra credit :),
 > where should I have looked to find the definitive answer to this
 > question?
 
 URLs are not HTML. They have their own syntax. In particular, the plus
 and equals signs have special meanings in a query string: the plus sign
 is interpreted as a space character and the equals sign is used to
 create a key/value association as you did in your own example,
 associating the key "myparam" with the value "four/two+5=5".
 
 The characters that have special meaning in a query string or that
 delimit the query string from other parts of the URL are the ones in the
 set {=?&;#%+}. When you use want to use any of these as an ordinary
 character, encode it as %nn where nn is the hexadecimal ASCII code for
 the character. An embedded space can be encoded as either %20 or a plus
 sign.
 
 See http://en.wikipedia.org/wiki/Percent-encoding.
 [Back to original message] |