第一种方法
public string ConvertTo_UTF8_String(string Msg){byte[] buff = new byte[Msg.Length / 2];string Message="";for (int i = 0; i < buff.Length; i++){buff = byte.Parse(Msg.Substring(i*2,2), System.Globalization.NumberStyles.AllowHexSpecifier);}Message=System.Text.UTF8Encoding.UTF8.GetString(buff);return Message;}
第二种方法: private string getultstr(string strcontent){string aaa = strcontent;int lenth = aaa.Length;for(int i=lenth-2;i>=0;i-=2){aaa = aaa.Insert(i,"0x");}int z = aaa.Length/4;byte[] asdf = new byte[z];for(int i=0;i<z;i++){asdf = Convert.ToByte(aaa.Substring(0,4),16);aaa = aaa.Substring(4);}return System.Text.Encoding.Default.GetString(asdf);}//
第三种方法
/// /// 十六进制字符串转成GB汉字字符串(如将"CED2C3C741"转换成"我们A") /// /// 要转换的字符串 /// 转换后的汉字串 private string hexstr2str(string hexstring) { System.Text.Encoding encode=System.Text.Encoding.GetEncoding("GB2312"); byte[] b=new byte[hexstring.Length/2]; for(int i=0;i<hexstring.Length/2;i++) { b[i]=Convert.ToByte("0x" + hexstring.Substring(i*2,2),16); } return encode.GetString(b); }