标签:
#region URL编码
/// <summary>
/// URL编码
/// </summary>
/// <param name="str">要进行编码的字符串</param>
/// <returns></returns>
public static string UrlEncode(string str)
{
StringBuilder sb = new StringBuilder();
byte[] byStr = System.Text.Encoding.UTF8.GetBytes(str); //默认是System.Text.Encoding.Default.GetBytes(str)
for (int i = 0; i < byStr.Length; i++)
{
sb.Append(@"%" + Convert.ToString(byStr[i], 16));
}
return (sb.ToString());
}
#endregion
标签:
原文地址:http://www.cnblogs.com/a-mumu/p/4335079.html