System.SysUtils
String byteToHexStr(TBytes ab) { String str;
for (int i = 0; i < 16; i++) { str += IntToHex(sbyte[i], 2); } return str; } void HexToByte(String HexStr, TBytes ab) { String byteStr; for (int i = 0; i < 15; i++) { byteStr = HexStr.SubString(i * 2 + 1, 2); byteStr = "0x" + byteStr; ab[i] = byteStr.ToInt(); } }

 

必须是16个字节

 16进制字符串

新方法不用循环啦

    TBytes bytes;
String str="您好";
    bytes=str.BytesOf();

TBytes bs16; bs16.set_length(bytes.Length
*2); BinToHex(bytes,0,bs16,0,bytes.Length);
s16
=TEncoding::ASCII->GetString(bs16);
Memo1
->Lines->Add(s16);

 

posted on 2015-09-28 18:56  lypzxy  阅读(587)  评论(0编辑  收藏  举报