Paul van Valkenburgh
Paul van Valkenburgh

Reputation: 75

Non-reserved yet safe characters for delimiters in a URL

I have seen the following on StackOverflow about URL characters:

There are two sets of characters you need to watch out for - Reserved and Unsafe. The reserved characters are:

  • ampersand ("&")
  • dollar ("$")
  • plus sign ("+")
  • comma (",")
  • forward slash ("/")
  • colon (":")
  • semi-colon (";")
  • equals ("=")
  • question mark ("?")
  • 'At' symbol ("@").

The characters generally considered unsafe are:

  • space,
  • question mark ("?")
  • less than and greater than ("<>")
  • open and close brackets ("[]")
  • open and close braces ("{}")
  • pipe ("|")
  • backslash ("\")
  • caret ("^")
  • tilde ("~")
  • percent ("%")
  • pound ("#").

I'm trying to code a URL so I can parse it using delimiters. They can't be numbers or letters though. Does anyone have a list of characters that are NOT Reserved but ARE safe to use?

Thanks for any help you can provide.

Upvotes: 3

Views: 2366

Answers (1)

JohnFx
JohnFx

Reputation: 34909

Don't bother trying to use safe/unreserved characters. Just use whatever delimiters you want and URLencode the whole thing. Then URL decode it on the other end and parse normally.

Is there a reason you can't just use the standard delimiter for URL parameters (&)? That is the most straightforward way to do it instead of trying to roll your own.

For example the standard URL syntax already allows for multi-valued paramaters natively. This is perfectly legal and doesn't require any trickery.

Somepage.aspx?parameterName=A&parameterName=B

The result is that the page would be passed "A,B" in the parameterName attribute.

Upvotes: 4

Related Questions