How can we encode a string using the URL (RFC 1738) standard in C#?
The following online tool is converting the strings using this standard http://www.freeformatter.com/url-encoder.html
An example of the string I want to convert is test(brackets)
and the encoded string should look like:
test%28brackets%29
According to RFC 1738:
Neither
HttpUtility.UrlEncode
norWebUtility.UrlEncode
will encode those characters since the standard says the parentheses()
can be used unencoded.I don't know why the URL Encoder / Decoder you linked encodes them since it also lists them as as a character that can be used in a URL.
Uri.EscapeDataString
does what you want. See MSDN.