Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpUtility.UrlEncode will not encode ! as %21

Tags:

c#

.net

urlencode

HttpUtility.UrlEncode("!!!test", Encoding.GetEncoding("windows-1251"))

It doesn't encode ! to %21 - why?

like image 351
kusanagi Avatar asked Mar 07 '11 13:03

kusanagi


People also ask

What is the difference between urlencode () and httputility ()?

The only difference is the UrlEncode (string) function has different outputs: The result is WebUtility.UrlEncode () is using lowercase while HttpUtility.UrlEncode () outputs UPPERCASE for the encoded characters. 2. Why the heck is that?

How to perform URL encoding in Java using urlencoder?

Java provides a URLEncoder class for encoding any query string or form parameter into URL encoded format. The following example demonstrates how to use URLEncoder.encode() method to perform URL encoding in Java. Pitfall to avoid: Do not encode the entire URL. Encode only the query string and path segment.

What is urlencode in ASP NET?

UrlEncode is a convenient way to access the UrlEncode method at run time from an ASP.NET application. Internally, UrlEncode uses the UrlEncode method to encode strings. To encode or decode values outside of a web application, use the WebUtility class.

How do I encode a URL in Python?

You can encode a URL using with the UrlEncode method or the UrlPathEncode method. However, the methods return different results. The UrlEncode method converts each space character to a plus character (+). The UrlPathEncode method converts each space character into the string "%20", which represents a space in hexadecimal notation.


1 Answers

Because it is a valid character on a URL and doesn't need to be encoded.

like image 89
Oded Avatar answered Oct 08 '22 12:10

Oded