Reputation: 37633
I used some online encoding detection so all of them are saying that
2015%2d03%2d31
is encoded by UTF8.
So I used this code to decode it and to see
2015-03-31
But it doesn't work.
private static string UTF8toASCII(string text)
{
System.Text.Encoding utf8 = System.Text.Encoding.UTF8;
Byte[] encodedBytes = utf8.GetBytes(text);
Byte[] convertedBytes =
Encoding.Convert(Encoding.UTF8, Encoding.ASCII, encodedBytes);
System.Text.Encoding ascii = System.Text.Encoding.ASCII;
return ascii.GetString(convertedBytes);
}
Any clue?
Upvotes: 0
Views: 313
Reputation: 21641
That's not UTF-8 encoded, it's URL Encoded. Use UrlDecode: https://msdn.microsoft.com/en-us/library/system.web.httputility.urldecode%28v=vs.110%29.aspx
return System.Web.HttpUtility.UrlDecode(text);
If your text might actually contain UTF-8 data, you could use this version:
return System.Web.HttpUtility.UrlDecode(Encoding.UTF8.GetBytes(text), Encoding.UTF8)
Upvotes: 2