tbytes 转 十六进制 string

function Bytes2HexStr(buf: TBytes; len: Integer): AnsiString;

begin

SetLength(Result, len*2);   BinToHex(@buf[0], PAnsiChar(Result), len);

end;

procedure TForm1.FormCreate(Sender: TObject);

var

bf: TBytes;   Str: AnsiString;

begin

bf := BytesOf('5677899090jjnm,nAB0098CDEFG');   rStr := Bytes2HexStr(bf, Length(bf));   ShowMessage(rStr);

end;

上一篇:【代码笔记】iOS-16进制颜色与UIColor互转


下一篇:常用标签介绍