在C#中怎样将一个字符串ENCODE成UTF8的URL格式?
1个回答
展开全部
Encoding gb2312 = Encoding.GetEncoding("gb2312");
Encoding utf8 = Encoding.UTF8;
//首先用utf-8进行解码
string key = HttpUtility.UrlDecode(oStr, utf8);
// 将已经解码的字符再次进行编码.
string encode = HttpUtility.UrlEncode(key, utf8).ToLower();
Encoding utf8 = Encoding.UTF8;
//首先用utf-8进行解码
string key = HttpUtility.UrlDecode(oStr, utf8);
// 将已经解码的字符再次进行编码.
string encode = HttpUtility.UrlEncode(key, utf8).ToLower();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询