• Server.UrlPathEncode和Server.UrlEncode的区别


    Server.UrlPathEncode默认使用的是utf-8编码而Server.UrlEncode默认为系统默认编码(一般是gb2312)

    Server.UrlDecode默认使用系统编码解码。所以这里容易发生路径解码成乱码的问题。

    Response.Write(Server.UrlDecode(Server.UrlPathEncode("中文")) & "<hr>") Response.Write(HttpUtility.UrlDecode(Server.UrlPathEncode("中文"), Encoding.UTF8) & "<hr>")

    解决办法: 解码的地方使用utf-8编码。HttpUtility.UrlDecode(Server.UrlPathEncode(String),  Encoding.UTF8);

                  或者编码的地方使用Server.UrlEncode(),编解码的默认编码方式都用gb2312;

    URL编码: System.Web.HttpUtility.UrlEncode(string); Server.UrlEncode(string); System.Web.HttpUtility.UrlPathEncode(string); Server.UrlPathEncode(string);

    UrlEncode与UrlPathEncode编码规范不一样 比如: UrlEncode对整个URL进行编码(即http://www.website.com/全部编码) UrlPathEncode对http://之后的内容进行编码(即www.website.com)

  • 相关阅读:
    数据库管理
    CodeSmith的运用正在完善中,待续
    各搜索引擎搜索代码
    浏览器本地存储
    QQ在线代码生成
    6组Alpha冲刺4/6
    结对编程作业
    camera相关
    数电、模电相关
    usb协议学习
  • 原文地址:https://www.cnblogs.com/lh123/p/3998198.html
Copyright © 2020-2023  润新知