According to the URL specification, %20
and +
are equivalent representations of an escaped space (ASCII 32). Whether a browser presents a %20
or +
is implementation-dependent.
Your site should be designed to handle both. Or really, it should not be working with the raw URL, but the unescaped and parsed URL-- which in either case would contain a space.
If you really are coding your web site to require that spaces be represented as a +
specifically, and this is somehow mission critical, you are setting yourself up for compatibility issues.
If you actually need a +
in the URL (unescaped), the hex code for that is %2B
.
Thus
Print(UrlEncode("This is a test")); = "This+is+a+test"
or "This%20is%20a%20test"
Print(UrlDecode("This%20is+a%20test")) = "This is a test"
Print(UrlEncode("What is 2+2?") = "What+is+2%2B2%3F"