0

I have ASCII encoding characters in string. Something like this:

%7B%22video%22%3A%7B%22JSONinfo%22%3A%7B%22id%22%3A212096%2C%22title

How can I decode it to "normal" string? I've tried to find an answer but I find solutions for byte[] of ASCII characters and so. I have an idea that I can replace all characters that starts with % by character which they represents but I think there is better aproach. And one more thing, solution must works for windows phone. Thanks

Libor Zapletal
  • 13,752
  • 20
  • 95
  • 182
  • possible duplicate of [Converting a string of ASCII into normal string C#](http://stackoverflow.com/questions/10349753/converting-a-string-of-ascii-into-normal-string-c-sharp) – eddie_cat Sep 10 '14 at 19:15
  • Yea, It looks that he was looking for same what I am (I didn't find this question) but there isn't best answer for this and it's `HttpUtility.UrlDecode`. – Libor Zapletal Sep 10 '14 at 19:23
  • Your question isn't phrased quite correctly then. What you have is a URL encoded string that you are trying to get the 'real' version of. – Paddy Sep 10 '14 at 19:41

2 Answers2

2

Use HttpUtility.UrlDecode(). For example, for the string you have given, the result is "{"video":{"JSONinfo":{"id":212096,"title"

Jogy
  • 2,465
  • 1
  • 14
  • 9
2

You have may alternatives. Choose whichever works for WP

string s = "%7B%22video%22%3A%7B%22JSONinfo%22%3A%7B%22id%22%3A212096%2C%22title";
var s1 = System.Web.HttpUtility.UrlDecode(s);
var s2 = System.Net.WebUtility.UrlDecode(s);
var s3 = System.Uri.UnescapeDataString(s);
L.B
  • 114,136
  • 19
  • 178
  • 224