Code
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
namespace Test_GetUTF8Website
{
class Program
{
static void Main(string[] args)
{
WebClient client = new WebClient();
string s = client.DownloadString("http://www.cnblogs.com");
string res = Encoding.UTF8.GetString(Encoding.Default.GetBytes(s));
Console.WriteLine(res);
Console.ReadLine();
}
}
}
大部分中文能正常显示,有部分会变成"??"(两个问号),请问如何解决?
byte[] bytes = client.DownloadData("http://www.cnblogs.com");
string res = Encoding.UTF8.GetString(bytes);