Http请求&GB2312编码

1 string httpurl = "http://www.baidu.com/";
2 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(httpurl);
3 //发送Http请求(即发送短信)
4 HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
5 //创建返回对象
6 StreamReader reader = new StreamReader(resp.GetResponseStream(), Encoding.GetEncoding("GB2312"));
7 //返回值 00 为发送成功
8 string html = reader.ReadToEnd();

 

 1 string smsIDs = row["SmsID"].ToString();
2 string smsContent = row["SmsContent"].ToString();
3 string mobile = row["SmsToTel"].ToString().Trim();
4 //将表中的短信内容转换为GB2312编码的字符串
5 StringBuilder sb = new StringBuilder();
6 byte[] byStr = System.Text.Encoding.GetEncoding("GB2312").GetBytes(smsContent);
7 for (int j = 0; j < byStr.Length; j++)
8 {
9 sb.Append(@"%" + Convert.ToString(byStr[j], 16));
10 }
11 string neirong = sb.ToString();
12 string httpurl = url + "?username="...

 

转载于:https://www.cnblogs.com/blogme/archive/2012/03/28/2421415.html