这不是十六进制ascii码,是进行了UrlEncode
public static string GetUrlEncode(string trueUrl)
{
return System.Web.HttpUtility.UrlEncode(trueUrl, System.Text.Encoding.GetEncoding("GB2312"));
}
public static string GetUrlDecode(string trueUrl)
{
return System.Web.HttpUtility.UrlEncode(trueUrl, System.Text.Encoding.GetEncoding("GB2312"));
}
Console.WriteLine("郑州:" + GetUrlEncode("郑州"));
Console.WriteLine("三门峡:" + GetUrlEncode("三门峡"));
运行结果:
郑州:%d6%a3%d6%dd
三门峡:%c8%fd%c3%c5%cf%bf
也可以参考这里
http://www.cnblogs.com/downmoon/archive/2007/12/30/1021140.html
byte[] bytes = System.Text.Encoding.Default.GetBytes(sc);
string reStr = string.Empty;
foreach (byte b in bytes)
{
short st = (short)(b - '\0');
reStr += st.ToString("x") + "%";
}
return "%" + reStr;