C#中的UrlEncode

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

System.Web.HttpUtility.HtmlEncode(str);
System.Web.HttpUtility.HtmlDecode(str);
//UrlEncode编码
System.Web.HttpUtility.UrlEncode(str);

如:

 Encoding gb2312 = Encoding.GetEncoding("gb2312");//Encoding.Default ,936
 string start = System.Web.HttpUtility.UrlEncode(“重庆”, gb2312);

 start =“%D6%D8%C7%EC”;

 

//UrlEncode解码
System.Web.HttpUtility.UrlDecode(str);

posted on 2015-09-18 16:09  三岁是笨蛋  阅读(775)  评论(0)    收藏  举报