当前位置: 代码迷 >> Windows Mobile >> WP怎么将编码方式为GB2312的网页正常显示出来呢
  详细解决方案

WP怎么将编码方式为GB2312的网页正常显示出来呢

热度:3534   发布时间:2013-02-26 00:00:00.0
WP如何将编码方式为GB2312的网页正常显示出来呢?
代码如下:

        private void GetScoreCallback(IAsyncResult result)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)result.AsyncState;
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
                Stream stream = response.GetResponseStream();
                StreamReader reader = new StreamReader(stream);
                resData = reader.ReadToEnd();
                ProcessResponseScore();
            }
            catch (Exception ee)
            {
                errorAsync = ee;
            }
        }

其中网页的源码保存在resData中,我通过MessageBox.Show()查看发现它的中文都是乱码,该如何处理呢?

------解决方案--------------------------------------------------------
http://encoding4silverlight.codeplex.com/
------解决方案--------------------------------------------------------

        private void GetScoreCallback(IAsyncResult result)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)result.AsyncState;
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
                Stream stream = response.GetResponseStream();
                StreamReader reader = new StreamReader(stream,new HtmlAgilityPack.Gb2312Encoding());
                resData = reader.ReadToEnd();;
                ProcessResponseScore();
            }
            catch (Exception ee)
            {
                errorAsync = ee;
            }
  相关解决方案