Bin2Hex Function

Action

Converts an ASCII representation of binary data into the hexadecimal representation.

Include file

Kernel.bdh

Syntax

Bin2Hex( in  sBinData : string,
         in  nBinLen  : number,
         out sHexData : string,
         in  nHexLen  : number optional ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sBinData String buffer containing the binary data to convert to hexadecimal notation
nBinLen Number of bytes to be converted
sHexData String receiving the hexadecimal representation of the binary data
nHexLen Maximum length of the string receiving the hexadecimal representation of the binary data. You have to specify at least 2*nBinLen+1 bytes to be able to convert all binary data to the hexadecimal representation. (optional) If the specified buffer is too small, the result will be truncated. In any case, the result will be NULL-terminated.

Example

transaction TMain
  var
    sString1, sString2: string;
  begin
    sString1 := "Test String";
    Bin2Hex(sString1, STRING_COMPLETE, sString2);
    writeln("Bin2Hex of <" + sString1 + "> is <" + sString2 + ">");
  end TMain;

Output

Bin2Hex of <Test String> is <5465737420537472696E67>