第一次尝试:
string question = textBox1.Text.ToString();
WebClient client= new WebClient();
client.Encoding = System.Text.Encoding.GetEncoding("GB2312");
Uri uri = new Uri("http://xxxxxxxxxxxxxx");
textBox1.Text =client.DownloadString(uri);
返回的字符串中有中文,出现乱码。
尝试n次后,解决办法如下:
string question = textBox1.Text.ToString();
WebClient client= new WebClient();
client.Encoding = System.Text.Encoding.GetEncoding("GB2312");
Uri uri = new Uri("http://xxxxxxxxxxxxxx");
textBox1.Text =Encoding.UTF8.GetString(client.DownloadData(uri));
先获取最基本的byte[]类型返回数据,然后转码成UTF8即可