WP 7 - HttpWebRequest编码ISO-8859-2

时间:2012-04-11 12:11:44

标签: c# html windows-phone-7 encoding

我有这段代码:

    private void HandleWebResponse(IAsyncResult asyncResult)
    {
        WebRequestState state = (WebRequestState)asyncResult.AsyncState;

        HttpWebRequest request = state.Request;
        string url = request.RequestUri.ToString();
        state.Response = (HttpWebResponse)request.EndGetResponse(asyncResult);
        string absolutePath = state.Response.ResponseUri.AbsolutePath;


        if (state.Response != null)
        {
            StreamReader reader = new StreamReader(state.Response.GetResponseStream(),Encoding.GetEncoding("ISO-8859-1"));
            StringBuilder sb = new StringBuilder();
            while (!reader.EndOfStream)
                sb.Append(reader.ReadLine());
            ...

我的网页编码为ISO-8859-2,但WP7不支持此编码。如何将此编码转换为另一种?或者你有提示如何绕过这个问题?每个建议都是如此。

1 个答案:

答案 0 :(得分:1)

只需使用Silverlight Encoding Generator即可获得所需的编码!