FUNCTION Byte_To_Hex(X : byte) : String2; { DESCRIPTION: Converts a byte into hexadecimal string. SAMPLE CALL: S := Byte_To_Hex(255); RETURNS: The hexadecimal representation of the specified value in a 2-bytes type string } var Digits : array [0..15] of char = '0123456789ABCDEF';BEGIN { Byte_To_Hex } Byte_To_Hex := Concat(Digits[X shr 4],Digits[X and 15]); END; { Byte_To_Hex }
{ DESCRIPTION:
Converts a byte into hexadecimal string.
SAMPLE CALL:
S := Byte_To_Hex(255);
RETURNS:
The hexadecimal representation of the specified value in a 2-bytes type
string }
var
Digits : array [0..15] of char = '0123456789ABCDEF';BEGIN { Byte_To_Hex }
Byte_To_Hex := Concat(Digits[X shr 4],Digits[X and 15]);
END; { Byte_To_Hex }
btw:这个方法是要遍历二进制串并处理,那有没有哪个Delphi函数或API能够直接对整个二进制串进行转换的呢?
再次感谢。