C# 如何在Windows Mobile上解码url编码字符串?

C# 如何在Windows Mobile上解码url编码字符串?,c#,windows-mobile,urlencode,C#,Windows Mobile,Urlencode,我已从服务器收到一个url编码字符串,例如http%3a%2f%2fstatic.csbew.com%2f%2fcreative%2fpd_test_pptv%2f320x60.png 我想把它解码成普通的url字符串。我找到了这种方法,但在紧凑型框架上不起作用 string url = System.Web.HttpUtility.UrlDecode(strURL, Encoding.GetEncoding("GB2312")); 知道如何解码字符串吗?也许这会帮助您: /// <s

我已从服务器收到一个url编码字符串,例如http%3a%2f%2fstatic.csbew.com%2f%2fcreative%2fpd_test_pptv%2f320x60.png

我想把它解码成普通的url字符串。我找到了这种方法,但在紧凑型框架上不起作用

string url = System.Web.HttpUtility.UrlDecode(strURL, Encoding.GetEncoding("GB2312"));

知道如何解码字符串吗?

也许这会帮助您:

 /// <summary>
    /// UrlDecodes a string without requiring System.Web
    /// </summary>
    /// <param name="text">String to decode.</param>
    /// <returns>decoded string</returns>
    public static string UrlDecode(string text)
    {
        // pre-process for + sign space formatting since System.Uri doesn't handle it
        // plus literals are encoded as %2b normally so this should be safe
        text = text.Replace("+", " ");
        return System.Uri.UnescapeDataString(text);
    }

    /// <summary>
    /// UrlEncodes a string without the requirement for System.Web
    /// </summary>
    /// <param name="String"></param>
    /// <returns></returns>
    public static string UrlEncode(string text)
    {
        // Sytem.Uri provides reliable parsing
        return System.Uri.EscapeDataString(text);
    }
//
///URL解码字符串而不需要System.Web
/// 
///要解码的字符串。
///解码字符串
公共静态字符串URL解码(字符串文本)
{
//+符号空间格式的预处理,因为System.Uri不处理它
//加上文字通常被编码为%2b,因此这应该是安全的
text=text.Replace(“+”,“”);
返回System.Uri.UnescapeDataString(文本);
}
/// 
///URL编码字符串,不需要System.Web
/// 
/// 
/// 
公共静态字符串UrlEncode(字符串文本)
{
//Uri提供了可靠的解析
返回System.Uri.EscapeDataString(文本);
}
最初在这里发现: