Unicode码如何转换为汉字啊?那位大神帮把手啊!我想要方法!!
6D 4B 8B D5 77 ED 4F E1 54 27 30 02 4E CA 59 29 59 29 6C 14 4E 0D 59 7D FF 0C 96 34 6C 89 6C 89 76 84 FF 0C 53 EF 80 FD 89 81 4E 0B 96 E8 30 02 5E 26 77 40 96 E8 4F 1E 4F DD 96 69 70 B9 51 3F FF 01
------解决方案-------------------- public static string DESDeCode(string Base64Str)
{
string factString = "";
byte[] myByte;
//先把字符串按照utf-8的编码转换成byte[]
Encoding myEncoding = Encoding.GetEncoding("utf-8");
//myByte中获得这样的字节数组:228,184,173,229,141,142,228,186,186,230,176,145,229,133,177,229,146,140,229,155,189
// myByte = myEncoding.GetBytes(factString);
//把byte[]转成base64编码,这个例子形成的base64编码的unicode等价字符串为:"5Lit5Y2O5Lq65rCR5YWx5ZKM5Zu9"
// Base64Str = Convert.ToBase64String(myByte);
//再从base64编码转成byte[],又恢复为字节数组:228,184,173,229,141,142,228,186,186,230,176,145,229,133,177,229,146,140,229,155,189
myByte = Convert.FromBase64String(Base64Str);
//用同一个Encoding对象把byte[]转成字符串:
factString = myEncoding.GetString(myByte);
return factString;
}
------解决方案--------------------LZ不带这样的试了好几个编码才发现是BE的。
“测试短信吧。今天天气不好,阴沉沉的,可能要下雨。带着雨伞保险点儿!”
C# code
string s = "6D 4B 8B D5 77 ED 4F E1 54 27 30 02 4E CA 59 29 59 29 6C 14 4E 0D 59 7D FF 0C 96 34 6C 89 6C 89 76 84 FF 0C 53 EF 80 FD 89 81 4E 0B 96 E8 30 02 5E 26 77 40 96 E8 4F 1E 4F DD 96 69 70 B9 51 3F FF 01";
byte[] bytes = s.Split(' ').Select(str => Convert.ToByte(str, 16)).ToArray();
string result = System.Text.Encoding.BigEndianUnicode.GetChars(bytes).Aggregate(new System.Text.StringBuilder(), (sb, c) => sb.Append(c)).ToString();
------解决方案--------------------