日期:2014-05-18  浏览次数:21196 次

System.Text.Encoding.UTF8.GetBytes问题!
string str= System.BitConverter.ToString( System.Text.Encoding.UTF8.GetBytes("你好"));

str得到的是"E4-BD-A0-E5-A5-BD"

请问怎么通过"E4BDA0E5A5BD"字符串反向得出“你好”

------解决方案--------------------
C# code

            string s = "E4BDA0E5A5BD";
            byte[] bs = new byte[s.Length / 2];
            int j = 0;
            for (int i = 0; i < s.Length; i+=2)
            {
                string str = s.Substring(i, 2);
                bs[j] = (byte)int.Parse(str, System.Globalization.NumberStyles.HexNumber);
                j++;
            }
            s = Encoding.UTF8.GetString(bs);