How do I decode this to get the result below?
/browse_ajax?action_continuation=1\u0026amp;continuation=4qmFsgJAEhhVQ2ZXdHFQeUJNR183aTMzT2VlTnNaWncaJEVnWjJhV1JsYjNNZ0FEZ0JZQUZxQUhvQk03Z0JBQSUzRCUzRA%253D%253D
/browse_ajax?action_continuation=1&continuation=4qmFsgJAEhhVQ2ZXdHFQeUJNR183aTMzT2VlTnNaWncaJEVnWjJhV1JsYjNNZ0FEZ0JZQUZxQUhvQk03Z0JBQSUzRCUzRA%253D%253D
I've tried these, also using them multiple times as I did read strings may be encoded multiple times.
System.Text.RegularExpressions.Regex.Unescape(string)
System.Uri.UnescapeDataString(string)
System.Net.WebUtility.UrlDecode(string)
Which is the right function here or rather in what order do I need to call them to get that result. As the strings vary there may be other special characters in the set so doing a workaround, editing it myself, is somewhat too risky.
The string has to be decoded to work with new System.Net.WebClient().DownloadString(string)
.
EDIT: So I found out the above statement is wrong, I do not have to decode this to use WebClient.DownloadString(string)
. However the downloaded string suffers similar encoding too. Setting the WebClient
's Encoding property to UTF8 inbefore downloading does most of the job, however some characters still seem corrupted, for example: Double quotes and ampersand stay \u0026quot;
and \u0026amp;
.
I don't know how to make \u0026 to &, so I can change & amp; to &.
Looked like the mysterium was solved to me, however I stumbled upon it again, didn't find any build in solution as these seem to fail decoding utf8 if the character is part of an html-escaped character.
As these however only seem to use the ampersand, I had to use Replace(@"\u0026","&")
to be able to HtmlDecode
and get a proper string.