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"),  
这是将一个字节转换为一个16进制字符串,"X"表示大写16进制字符,用"x"可以得到小写的。  


参考
字符串(含有汉字)转化为ascII16进制问题
http://topic.csdn.net/t/20040905/22/3342635.html

字符串(含有汉字)转化为16进制编码进制        public string EncodingSMS(string s)
        }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
  • 2021-10-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2021-05-18
  • 2021-08-20
相关资源
相似解决方案