复制代码 代码如下:
protected string UrlEncode(string url)
...{
byte[] bs = Encoding.GetEncoding("GB2312").GetBytes(url);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < bs.Length; i++)
...{
if (bs[i] < 128)
sb.Append((char)bs[i]);
else
...{
sb.Append("%" + bs[i++].ToString("x").PadLeft(2, '0'));
sb.Append("%" + bs[i].ToString("x").PadLeft(2, '0'));
}
}
return sb.ToString();
}
新闻热点
疑难解答
图片精选