public static string Str2Hex(string s)
{
string result = string.Empty;
byte[] arrByte = System.Text.Encoding.GetEncoding("GB2312").GetBytes(s);
for(int i = 0; i < arrByte.Length; i++)
{
result += "&#x" + System.Convert.ToString(arrByte[i], 16) + ";"; //Convert.ToString(byte, 16)把byte转化成十六进制string
}
return result;
}
变成可以在网上传输的那种16进制编码,类似%8D%E2这种?这样的话,
用System.Web.HTTPUtility.URLEncode()就行。
光光10进制转换到16进制的话,可以用 bytes(i).ToString("X"),<PRe style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0
新闻热点
疑难解答