C#中将中文字符转换成url编码

1 Encoding gb2312 = Encoding.GetEncoding("gb2312");
2 Encoding utf8 = Encoding.UTF8;
3 //首先用utf-8进行解码
4 string key = HttpUtility.UrlDecode(oStr, utf8);
5 // 将已经解码的字符再次进行编码.
6 string encode = HttpUtility.UrlEncode(key, utf8).ToLower();

 

posted @ 2022-04-21 13:38  學海無邊  阅读(1131)  评论(0)    收藏  举报