二进制字节数组和16进制字符串相互转换
二进制字节数组和16进制字符串相互转换
TBytes(二进制字节数组)要持久化到文件或数据库之前,要转换为16进制字符串。
DELPHI提供了一组函数。
uses classes
procedure BinToHex(Buffer: PAnsiChar; Text: PWideChar; BufSize: Integer); overload; procedure BinToHex(Buffer: PAnsiChar; Text: PAnsiChar; BufSize: Integer); overload; procedure BinToHex(var Buffer; Text: PWideChar; BufSize: Integer); overload; inline; procedure BinToHex(var Buffer; Text: PAnsiChar; BufSize: Integer); overload; inline; procedure BinToHex(Buffer: Pointer; Text: PWideChar; BufSize: Integer); overload; inline; procedure BinToHex(Buffer: Pointer; Text: PAnsiChar; BufSize: Integer); overload; inline; function HexToBin(Text: PWideChar; Buffer: PAnsiChar; BufSize: Integer): Integer; overload; function HexToBin(Text: PAnsiChar; Buffer: PAnsiChar; BufSize: Integer): Integer; overload; function HexToBin(Text: PWideChar; var Buffer; BufSize: Integer): Integer; overload; inline; function HexToBin(Text: PAnsiChar; var Buffer; BufSize: Integer): Integer; overload; inline; function HexToBin(Text: PWideChar; Buffer: Pointer; BufSize: Integer): Integer; overload; inline; function HexToBin(Text: PAnsiChar; Buffer: Pointer; BufSize: Integer): Integer; overload; inline;
procedure BinToHex(const Buffer: TBytes; BufOffset: Integer; var Text: TBytes; TextOffset: Integer; Count: Integer); overload; function HexToBin(const Text: PChar; TextOffset: Integer; var Buffer: TBytes; BufOffset: Integer; Count: Integer): Integer; overload; function HexToBin(const Text: TBytes; TextOffset: Integer; var Buffer: TBytes; BufOffset: Integer; Count: Integer): Integer; overload;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/10396098.html