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

标签 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"));

知道如何解码字符串吗?

最佳答案

也许这对你有帮助:

 /// <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);
    }

最初在这里找到:geekstoolbox

关于c# - 如何在 Windows Mobile 上解码 url 编码字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3227065/

相关文章:

c# - SQL 存储过程未返回小数位

c# - 如何知道 WCF 服务是否使用 protobuf-net?

c# - 在 C# 中使用 XSLT 将 XML 转换为 HTML 的最简单方法?

.net - 为什么紧凑框架WebBrowser控制opera中的加载页面?

javascript - 检查部分 URL 是否已编码

JavaScript URL 解码功能

c# - C# 中的二维数组以及如何返回数组

c# 如何读取 Windows 移动设备 6 上的消息存储

qt - Windows Mobile中的非关闭关闭按钮(使用Qt开发)

java - REST WS 的编码解码变音符号