I'm not familiar with this encoding, what is it and how do I decode it in C#?
\u00257B\u002522target_id\u002522\u00253A\u002522p\u00257C29681347\u002522\u00252C+\u002522prop_id\u002522\u00253A\u0025222\u002522\u00252C+\u002522tid\u002522\u00253A\u0025221316开发者_StackOverflow132877\u002522\u00252C+\u002522
Assuming that it's a C# string literal like this
string text = "\u00257B\u002522target_id\u002522\u00253A\u002522p...";
then you don't need to decode it at all. It's just a string literal that happens to contain an escape code.
The escape code \udddd (where dddd is a four-digit number) represents the Unicode character U+dddd. Eight-digit Unicode escape codes are also recognized: \Udddddddd.
So \u0025
represents the character %
.
If you display the string, e.g.
Console.WriteLine(text);
you get the following output:
%7B%22target_id%22%3A%22p...
The output looks like an URL encoded string. You can decode it using the Uri.UnescapeDataString Method:
string decoded = Uri.UnescapeDataString(text);
// decoded == "{\"target_id\":\"p..."
If you display the decoded string
Console.WriteLine(decoded);
you get the following output:
{"target_id":"p...
Use System.Web.HttpUtility.UrlDecode() on that string to get
{"target_id":"p|29681347", "prop_id":"2", "tid":"1316132877", "
Clearly it is a fragment of the entire string.
That's a unicode representation for a keyvalue pair list:
{"target_id":"p|29681347",+"prop_id":"2",+"tid":"1316132877",+"
You can decode it with the common System.Text.Encoding.Unicode classes.
精彩评论