向一网站post数据,其中要提交很多中文字符,通过sniffer得到“成都市”提交时转变为""%B3%C9%B6%BC%CA%D0".试过HttpUtility.UrlEncode(),发现不是用的这个编码。该编码是什么格式呀?希望高手给以帮助,不胜感激!
postStr += "&city=" + "%B3%C9%B6%BC%CA%D0";
byte [] postData = System.Text.Encoding.ASCII.GetBytes(postStr);
System.Net.WebClient client = new System.Net.WebClient ();
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
client.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)");
client.Headers.Add("Accept", "*/*)");
try
{
byte [] returnData = client.UploadData(postUrl, "POST", postData);
returnString = System.Text.Encoding.GetEncoding("GB2312").GetString(returnData);
}
postStr += "&city=" + "%B3%C9%B6%BC%CA%D0";
byte [] postData = System.Text.Encoding.ASCII.GetBytes(postStr);
System.Net.WebClient client = new System.Net.WebClient ();
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
client.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)");
client.Headers.Add("Accept", "*/*)");
try
{
byte [] returnData = client.UploadData(postUrl, "POST", postData);
returnString = System.Text.Encoding.GetEncoding("GB2312").GetString(returnData);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货