public static string UrlEncode(string str)
{
StringBuilder sb = new StringBuilder();
byte[] byStr = System.Text.Encoding.Default.GetBytes(str);
for(int i = 0; i < byStr.Length; i++)
{
sb.Append(@"%" + Convert.ToString(byStr[i],16));
}
return (sb.ToString());
}
{
StringBuilder sb = new StringBuilder();
byte[] byStr = System.Text.Encoding.Default.GetBytes(str);
for(int i = 0; i < byStr.Length; i++)
{
sb.Append(@"%" + Convert.ToString(byStr[i],16));
}
return (sb.ToString());
}
C#的一段返回UrlEncode加密格式的代码~
UrlEncode加密就是在网址中。。那个汉字加密成%xxx%xxx那样的
来源:https://www.cnblogs.com/shiweifu/archive/2008/01/13/1037217.html