Decoding strings in c#
I have an app that works with some texts and I need to decode strings like:
example\x27s开发者_JAVA百科 string
example\u0027s string
For the first one I tried using Uri.UnescapeDataString(string.Replace("\\x", "%"))
which works but not always because if the string is something like "the 40% of somethings's stuff", it throws an Exception
because of the "40%".
For the second one I don't really know how to decode that.
Is there something I can use to decode those two kind of strings?
Try:
System.Web.HttpUtility.UrlDecode(input);
Results:
"example\x27s string" -> "example's string"
"example\u0027s string" -> "example's string"
See MSDN.
精彩评论