zoukankan      html  css  js  c++  java
  • 控制台或Winform程序中如何编码或解码Server.URLEncode

    在Asp.net中可以使用Server.HTMLEncode和Server.URLEncode 将文本或URL的特殊字符编码,
    但在控制台或Winform程序中没有办法使用到这些方法,

    解决办法:

    右击项目==》添加引用==》.NET==》System.Web==》确定

    System.Web.HttpUtility.HtmlEncode(str);
    System.Web.HttpUtility.HtmlDecode(str);

    System.Web.HttpUtility.UrlEncode(str);

    System.Web.HttpUtility.UrlDecode(str);




    编码后得到的字串和用Server.URLEncode编码得到的不一样,那边接收到的也是乱码??

    编码时可以指定编码的,如
    System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.Unicode);
    System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.UTF8);
    System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.GetEncoding( "GB2312 "));


    解码也可以指定编码的
    System.Web.HttpUtility.UrlDecode(str,System.Text.Encoding.Unicode);
    System.Web.HttpUtility.UrlDecode(str,System.Text.Encoding.UTF8);
    System.Web.HttpUtility.UrlDecode(str,System.Text.Encoding.GetEncoding( "GB2312 "));

    出现乱码是编码设置造成的。你可以试试不同的方法。

    来自:http://hi.baidu.com/handboy/blog/item/1555601678c02b15962b4341.html


  • 相关阅读:
    windows本地提权——2003笔记
    Windows与linux添加用户命令
    反弹shell集锦
    提权-特权升级
    常见端口
    git泄露利用脚本
    Thinkphp5命令执行利用
    Thinkphp2.1漏洞利用
    打ms15-034补丁出现“此更新 不适用于您的计算机”
    Hyda爆破
  • 原文地址:https://www.cnblogs.com/liancs/p/3879296.html
Copyright © 2011-2022 走看看