views:

63

answers:

1

What are the valid characters that can be used in a URL query variable?

I'm asking because I would like to create GUIDs of minimal string length by using the largest character set so long as they can be passed as a URL query variable (www.StackOverflow.com?query=guiddaf09834fasnv)

Edit

If you want to encode a UUID/GUID or any other information represented in a byte array into a url-friendly string, you can use this method in the Apache Commons Code library:

Base64.encodeBase64URLSafeString(byte[])
+2  A: 

When in doubt, just go to the RFC.

Note: A query variable is not dealt with any differently then the rest of the URL.

From the section "2.2. URL Character Encoding Issues"

... only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL.

Dan McGrath