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

发布于 2024-09-09 05:13:45 字数 299 浏览 3 评论 0原文

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

我想将其解码为正常的网址字符串。我找到了这个方法,但这不适用于紧凑框架。

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

关于如何解码字符串有什么想法吗?

I have received an url encoding string from the server, e.g http%3a%2f%2fstatic.csbew.com%2f%2fcreative%2fpd_test_pptv%2f320x60.png

I want to decode it to normal url string. I find this method, but this doesn't work on compact framework.

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

Any idea about how to decode the string?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼趣 2024-09-16 05:13:45

也许这会对您有所帮助:

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

最初在这里找到:极客工具箱

Maybe this will help you:

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

Originally found here: geekstoolbox

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文