C#中Winform如何获取HTTPUtility.UrlEncode
2014-07-04 09:37
375 查看
前一段时间做了个WinfROm版本的web服务器,结果抓取到地址栏中的参数,是乱码,豁然间想到了用UrlEncode,失望的是没有,然后我在程序集中点引用,在.NETFramework中引用也没有如下图:
后来想了想那么我通过浏览来找,C盘Windows找到了下图:
哈哈,就这样问题解决了,Ok问题解决以后,
问题又来了
通过以下方式可以解决
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 "));
后来想了想那么我通过浏览来找,C盘Windows找到了下图:
哈哈,就这样问题解决了,Ok问题解决以后,
问题又来了
通过以下方式可以解决
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 "));
相关文章推荐
- C#里HttpUtility.UrlEncode和JS端转换的心得
- C# Winform中如何获取文件路径
- C# HttpUtility.UrlEncode 与 JAVA URLEncoder.encode 区别
- C#中如何通过HTTP协议的不同请求方式获取数据
- 如何在C#中使用HttpServerUtility.MapPath()方法
- c#asp.net url 传递中文参数要使用 System.Web.HttpUtility.UrlEncode 而不能使用Server.UrlEncode
- C# WinForm 获取 http 网络图片
- C# Winform中如何获取文件名与文件路径
- c#asp.net url 传递中文参数要使用 System.Web.HttpUtility.UrlEncode 而不能使用Server.UrlEncode
- c#asp.net url 传递中文参数要使用 System.Web.HttpUtility.UrlEncode 而不能使用Server.UrlEncode
- c# winform程序如何获取命令行带参数启动时的参数
- C# Winform程序如何获取运行路径, 控制台也可以
- c#winform中如何获取网页中HTML的标题
- C#如何通过Socket的方式获取httponly cookie
- C#如何通过SOCKET的方式获取HTTPONLY COOKIE
- C# HttpUtility.UrlEncode 与 Java URLEncoder.encode的转换方法,李逵与李鬼
- C# Winform 中如何获取本机安装输入法,并设置为默认输出语言,如何打开搜狗输入法和手写板
- 看C#实现源码,可以参考算法 HttpUtility.UrlEncode
- C# Winform中如何获取文件路径