using System;
using System.Globalization;
using System.Text;
public static class MobileUtil
{
public static char HexToUnicode(string hex)
{
byte[] bytes = HexToBytes(hex);
char c;
if (bytes.Length == 1)
{
c = (char)bytes[0];
}
else if (bytes.Length == 2)
{
c = (char)((bytes[0] << 8) + bytes[1]);
}
else
{
throw new Exception(hex);
}
return c;
}
public static byte[] HexToBytes(string hex)
{
hex = hex.Trim();
byte[] bytes = new byte[hex.Length / 2];
for (int index = 0; index < bytes.Length; index++)
{
bytes[index] = byte.Parse(hex.Substring(index * 2, 2), NumberStyles.HexNumber);
}
return bytes;
}
}