c# UrlEncode,UrlDecode

用 C#  winform  處理 utf-8,gb2312編碼轉換方法框架

首先,在項目屬性 的  應用程序——目標框架中,選擇 .NET Framework 4編碼

而後再添加引用——.NET 中選擇  System.Web,在代碼中也加引入 using System.Web;code

接下來直接寫代碼:orm

HttpUtility.UrlEncode(text);  //utf-8 編碼
HttpUtility.UrlDecode(text);  //utf-8 解碼
HttpUtility.UrlEncode(text, System.Text.Encoding.GetEncoding(936));  //gb2312編碼
HttpUtility.UrlDecode(text, System.Text.Encoding.GetEncoding(936));  //gb2312解碼
相關文章
相關標籤/搜索