"Sputnik" help  
Sputnik Help
BinaryFromHex(<string>, [<separator>])

Description

Converts a hexadecimal string to its binary representation. Each pair of hexadecimal digits is converted to a byte in the binary string. The input <string> should only contain valid hexadecimal characters (0-9, A-F) in uppercase. Optionally, you can specify a <separator> character to be removed from the input <string> before conversion.

Parameters

<string> The hexadecimal string to be converted to binary.
<separator> Optional separator character to be removed from the input <string>. (Default: Empty String)

Return Value

Success: Returns binary string representing the binary representation of the hexadecimal string.
Failure: Returns an empty binary string.

Remarks

The BinaryFromHex function allows you to convert a hexadecimal string back to its original binary form. This is particularly useful when processing hexadecimal data received from external sources or when reconstructing binary data from its hexadecimal representation. The function automatically converts the hexadecimal string to its corresponding binary form, enabling you to work with the original binary data seamlessly. Additionally, you can optionally specify a <separator> character to remove before conversion, allowing flexibility in handling formatted hexadecimal input.

Related

BinaryToHex

Example

Example of usage:

my $hex = BinaryToHex(bin("Hello world!"));
say $hex;
my $bin = BinaryFromHex($hex);
say BinaryExpand($bin, false);

my $hex = BinaryToHex(bin("Hello world!"), "-");
say $hex;
my $bin = BinaryFromHex($hex, "-");
say BinaryExpand($bin, false);

// PRINTS
// 48656C6C6F20776F726C6421
// 48 65 6C 6C 6F 20 77 6F 72 6C 64 21 -- -- -- -- Hello world!
// 48-65-6C-6C-6F-20-77-6F-72-6C-64-21
// 48 65 6C 6C 6F 20 77 6F 72 6C 64 21 -- -- -- -- Hello world!

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org