S
S
Slavik Smirnov2017-04-18 19:55:24
In contact with
Slavik Smirnov, 2017-04-18 19:55:24

Encoding in C# when working with JSON?

Hello! There is this piece of code:

public string Req(string m, string s, string t)
        {
            string method = m;
            string settings = s;
            string token = t;

            var url = "https://api.vk.com/method/"+ method+"?"+settings+ "&access_token="+token+"&v=5.63";
            WebClient client = new WebClient();
            var json = client.DownloadString(url);
            return json;
        }

Json comes in the wrong encoding. What to do? How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem, 2017-04-18
@fooxboy

Well, actually, https://msdn.microsoft.com/ru-ru/library/system.ne...
Either Encoding.UTF8 or Encoding.GetEncoding(1251)
It is unlikely that ru-services will use other encodings, although not excluded (read VK API documentation)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question