I've been trying to decode %E9(é).
WebUtility.HtmlDecode("%E9")
doesn't work. It puts a ? sign instead of a é.
I've been trying to decode %E9(é).
WebUtility.HtmlDecode("%E9")
doesn't work. It puts a ? sign instead of a é.
I've tested this and found that HttpUtility.UrlDecode("%E9")
returns question mark that You mentioned. It seems that it You have to manually specify appropriate encoding for this to work correctly with %E9
encoded value.
You can try:
HttpUtility.UrlDecode("%E9", System.Text.UnicodeEncoding.Default);
or
HttpUtility.UrlDecode("%E9", System.Text.UnicodeEncoding.UTF7);
Both should return the character decoded as You expected.
For Url decode, you should use UrlDecode instead of HtmlDecode. Also, you need to specify the encoding for this to work because the encoded value %E9
is not UTF-8
value, and by default UrlDecode
returns string decoded using UTF-8
.
Addition to Lukasz's answer, you can also use:
HttpUtility.UrlDecode("%E9", System.Text.Encoding.GetEncoding("iso-8859-1"));