How can I properly URL encode a string in PHP?

For the URI query use urlencode/urldecode; for anything else use rawurlencode/rawurldecode. The difference between urlencode and rawurlencode is that urlencode encodes according to application/x-www-form-urlencoded (space is encoded with +) while rawurlencode encodes according to the plain Percent-Encoding (space is encoded with %20).

.net UrlEncode – lowercase problem

I think you’re stuck with what C# gives you, and getting errors suggests a poorly implemented UrlDecode function on the other end. With that said, you should just need to loop through the string and uppercase only the two characters following a % sign. That’ll keep your base64 data intact while massaging the encoded characters … Read more

How do you UrlEncode without using System.Web?

System.Uri.EscapeUriString() can be problematic with certain characters, for me it was a number / pound ‘#’ sign in the string. If that is an issue for you, try: System.Uri.EscapeDataString() //Works excellent with individual values Here is a SO question answer that explains the difference: What’s the difference between EscapeUriString and EscapeDataString? and recommends to use … Read more

How do I encode URI parameter values?

Jersey’s UriBuilder encodes URI components using application/x-www-form-urlencoded and RFC 3986 as needed. According to the Javadoc Builder methods perform contextual encoding of characters not permitted in the corresponding URI component following the rules of the application/x-www-form-urlencoded media type for query parameters and RFC 3986 for all other components. Note that only characters not permitted in … Read more

What is %2C in a URL?

Check out http://www.asciitable.com/ Look at the Hx, (Hex) column; 2C maps to , Any unusual encoding can be checked this way +—-+—–+—-+—–+—-+—–+—-+—–+ | Hx | Chr | Hx | Chr | Hx | Chr | Hx | Chr | +—-+—–+—-+—–+—-+—–+—-+—–+ | 00 | NUL | 20 | SPC | 40 | @ | 60 | … Read more

How to encode the plus (+) symbol in a URL

The + character has a special meaning in a URL => it means whitespace – . If you want to use the literal + sign, you need to URL encode it to %2b: body=Hi+there%2bHello+there Here’s an example of how you could properly generate URLs in .NET: var uriBuilder = new UriBuilder(“https://mail.google.com/mail”); var values = HttpUtility.ParseQueryString(string.Empty); … Read more