Show: Delphi C++
Display Preferences

System.Classes.BinToHex

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure BinToHex(const Buffer: TBytes; BufOffset: Integer; var Text: TBytes; TextOffset: Integer; Count: Integer);
procedure BinToHex(Buffer: PAnsiChar; Text: PAnsiChar; BufSize: Integer);
procedure BinToHex(Buffer: PAnsiChar; Text: PWideChar; BufSize: Integer);
procedure BinToHex(var Buffer; Text: PWideChar; BufSize: Integer);
procedure BinToHex(var Buffer; Text: PAnsiChar; BufSize: Integer);
procedure BinToHex(Buffer: Pointer; Text: PWideChar; BufSize: Integer);
procedure BinToHex(Buffer: Pointer; Text: PAnsiChar; BufSize: Integer);

C++

extern DELPHI_PACKAGE void __fastcall BinToHex(const System::DynamicArray<System::Byte> Buffer, int BufOffset, System::DynamicArray<System::Byte> &Text, int TextOffset, int Count)/* overload */;

Properties

Type Visibility Source Unit Parent
procedure
function
public
System.Classes.pas
System.Classes.hpp
System.Classes System.Classes

Description

Converts a binary value into a string that is its hexadecimal representation.

Call BinToHex to convert the binary value Buffer into a string that is its hexadecimal representation.

This procedure receives the following parameters:

Parameter Description

Buffer

Pointer to an array of bytes.

For example: 00011101 11101100 10101111.

BufOffset
(optional)

Number of bytes to skip at the beginning of the input array of bytes.

For example, if Buffer is 00011101 11101100 10101111 and BufOffset is 2, only 00011101 11101100 is converted to hexadecimal.

Text

Pointer to the string that will receive the value of the input bytes as a string of hexadecimal characters.

For example, for the input bytes 00011101 11101100 10101111, the output string would be "1decaf".

Notes:
  • The output hexadecimal number is in upper-case characters.
  • BinToHex writes the output string as a null-terminated string.

TextOffset
(optional)

Number of characters to skip at the beginning of the input string.

For example, if Text is "608da975" before you call BinToHex and TextOffset is 4, BinToHex starts writing the output value on the fifth character, and the first 4 characters ("608d") remain unchanged.

BufSize or
Count

Number of bytes (pairs of hexadecimal characters) from the input array of bytes to convert into the output string.

Note: This value should be either equal or lower than both the length of the input array of bytes or half the length of the input string. For example:
  • If the input array is 8 bytes long, this number should be 8 or lower.
  • If the output string is 8 characters long, this number should be 4 or lower.
  • If the input array is 8 bytes long and the output string is 8 characters long, this number should be 4 or lower (because of the string length).

You can call BinToHex with or without specifying an offset for the input string (TextOffset) or the output buffer (BufOffset). However, you must specify either both offsets or specify none of them.

See Also

Code Examples

Personal tools
In Other Languages
Previous Versions
Assistance