c#编码解码---间断更新中

server.UrlEncode() 方法

Asp.net中可以使用以下2种方法 将文本或URL的特殊字符编解码:

编码:

Server.HTMLEncode【HttpUtility.UrlEncode(字符串,Encoding.Default)

Server.URLEncode按照 UTF-8 编码方式进行处理的

解码:

Server.UrlDecode(字符串)


但在控制台或Winform程序中没有办法使用到这些方法:解决办法:
右击项目==》添加引用==》.NET==》System.Web==》确定。

编码时可以指定编码的,如 
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 “)); 等 。



    原文作者:游程编码问题
    原文地址: https://blog.csdn.net/lijingrong_ljr/article/details/53159202
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞