I have a JSON string result(in persian language) from a webservive.
But the results from the web service are as this:
"\آ\د\ر\س \ا\ی\م\ی\ل"
While the original text is as follows:
عملیات انجام شد
how to Conversion from unicode to original format C#
this is my code
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://webserver.com/");
request.Method = "GET";
request.ContentLength = 0;
request.Credentials = CredentialCache.DefaultCredentials;
request.ContentType = "application/xml";
request.Accept = "application/xml";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (Stream receiveStream = response.GetResponseStream())
{
using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
{
string strContent = readStream.ReadToEnd();
}
}
}
That looks like JSON. You would need parse it .
To confirm it, you could take the output and run it through an online decoder for example http://json.parser.online.fr/
{ "a": "\u0622\u062f\u0631\u0633 \u0627\u06cc\u0645\u06cc\u0644" }
So to parse that in C#
string strContent = readStream.ReadToEnd();
dynamic stuff = JsonConvert.DeserializeObject(strContent);
You should be able to find out what structure is being returned by the web service - usually this is documented. Not much point creating a web service unless you tell people how to use it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.