Windows Phone HttpClient解析gb2312网页

来源:互联网 发布:xn网络词汇是什么意思 编辑:程序博客网 时间:2024/06/03 17:42

因为Windows Phone默认不支持GB2312编码,HttpClient本身也不提供GB2312编码。

如果想使用需借用第三方库实现(即Encoding4Silverlight),具体导入参考官方文档

var client = new HttpClient();var response = await client.GetByteArrayAsync(url);var responseString = DBCSCodePage.DBCSEncoding.GetDBCSEncoding("GB2312").GetString(response, 0, response.Length - 1);


另外网上大部分是没有使用Httpclient,而选用了WebClient, 使用WebClient的方法具体参见:  Windows Phone 8 使用GB2312编码的办法

0 0