1.你可以试试,我就是这样写的没有问题
using System.Text; System.Byte[] btaaa;
btaaa = System.Text.Encoding.Default.GetBytes("京"); 2.自己写一个函数就行了吧.建议你先去Convert类里面去找找,可能有现成的
如果没有
自己写一个,算法如下,你改一下就行(这是我在数据库中做的函数,来处理十进制转16进制的方法)
WHILE @num>0
BEGIN
SET @sResult=SUBSTRING('0123456789ABCDEF',@num%16+1,1) + @sResult
SET @num = @num/16
END
using System.Text; System.Byte[] btaaa;
btaaa = System.Text.Encoding.Default.GetBytes("京"); 2.自己写一个函数就行了吧.建议你先去Convert类里面去找找,可能有现成的
如果没有
自己写一个,算法如下,你改一下就行(这是我在数据库中做的函数,来处理十进制转16进制的方法)
WHILE @num>0
BEGIN
SET @sResult=SUBSTRING('0123456789ABCDEF',@num%16+1,1) + @sResult
SET @num = @num/16
END
using System.Text;byte[] bytes;
char achar = '京';
bytes=Encoding.GetEncoding("GB2312").GetBytes(achar.ToString());16进制字节字符串的输出要自己写函数:
private static char[] hexDigits = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};public static string ToHexString(byte[] bytes)
{
char[] chars = new char[bytes.Length * 2];
for (int i = 0; i < bytes.Length; i++)
{
int b = bytes[i];
chars[i * 2] = hexDigits[b >> 4];
chars[i * 2 + 1] = hexDigits[b & 0xF];
}
return new string(chars);
}