日期:2014-05-18 浏览次数:20863 次
const string input = @"86@86@80@8A@80@85@83@8B@0BEA@04A2@78A8@66CF@0AA8@78D9@"; var bytes = new List<byte>(); foreach (var seg in input.Split('@').Where(s => !string.IsNullOrEmpty(s))) { switch (seg.Length) { case 4: var word = BitConverter.GetBytes((Int16) (Int16.Parse(seg, NumberStyles.HexNumber) ^ 0xB209)); bytes.Add(word[1]); bytes.Add(word[0]); break; case 2: bytes.Add((byte) (byte.Parse(seg, NumberStyles.HexNumber) ^ 0xB2)); break; default: break; } } var text = Encoding.GetEncoding("gb2312").GetString(bytes.ToArray());