I'm using HttpUtility.UrlEncode to turn parameter value which concluds '+' to safe string deliverd among pages, so it turns '+' into %2b, but when I use Decode method it give me back a space. Why?
HttpServerUtility. UrlEncode Method (System. Web) Encodes a string for reliable HTTP transmission from the Web server to a client through the URL.
URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20.
URLDECODE is a string manipulation function that manipulates CHARACTER string data.
This is a type of encoding-decoding approach where the built-in PHP functions urlencode() and urldecode()are implemented to encode and decode the URL, respectively. This encoding will replace almost all the special characters other than (_), (-), and (.) in the given URL.
Decoding %2b
would give you back a +
, but decoding a +
would give you back a space.
So, most likely your string is decoded twice. If you are reading it from the Request.Querystring
collection, then it's already decoded, so you shouldn't decode it again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With