Which special characters are safe to use in url?
The safe characters are a-z, A-Z, 0-9, and _ - (underscore and minus), that besides the reserved characters who are used for the parameters.
Other characters will give problems in some degree. example: if one parameter is an array
?param=array[content] ie will show an url whit the square brackets url encoded, which look ugly and impossible to dictate.
But the problem is not only it's ugly, lets say you have a jpg with a character beside the safer ones, many times the browser will be unable to download it getting a 404. This is a problem of older browsers and some mobile browsers.
How to test this?
- put a bunch of images/js/css with the characters you want to test in the names in a public page with many visitors
- Make the 404 page send you a email every time it get a hit
I have an inbox with 14000 emails proving my point.
The following characters have special meaning in the path component of your URL (the path component is everything before the '?'):
";" | "/" | "?"
In addition to those, the following characters have special meaning in the query part of your URL (everything after '?'). Therefore, if they are after the '?' you need to escape them:
":" | "@" | "&" | "=" | "+" | "$" | ","
For a more in-depth explanation, see the RFC.
The answers here are good, but there is one more exception I think is worth mentioning - non-english characters. Referencing this SF question here, characters like ñ (as in Español) are perfectly legitimate, IF they have been encoded in your DNS correctly.
You have to use Punycode within your DNS to get them to resolve in modern browsers (the entry for español is
xn--espaol-zwa) but these are now perfectly safe to use in domain names, as they're easy for non-english-speakers to type as well.