"Sputnik" help  
Sputnik Help
BinA(<value>)

Description

Converts between binary strings and arrays of bytes.

Parameters

<value> If binary, returns an array of bytes; if an array, returns a binary string with each byte cast from array elements.

Return Value

Success: Returns an array or binary string based on the input type.
Failure: Returns an empty binary string (this may be desired though).

Remarks

The BinA function facilitates the conversion between binary strings and arrays of bytes. When provided with a binary string, it transforms it into an array where each element represents one byte. When given an array, it creates a binary string with each byte cast from the array elements.

Related

Pack

Example

Example of usage:

// make binary and print it
my $bin = (binary)"Hello";
say BinaryExpand($bin, false);

// convert binary to array and print it
my $arr = Bina($bin);
printr $arr;

// convert array to binary and print it
my $newBin = Bina($arr);
say BinaryExpand($newBin, false);

// PRINTS
// 48 65 6C 6C 6F -- -- -- -- -- -- -- -- -- -- -- Hello
// Array
// (
//     [0] => 72
//     [1] => 101
//     [2] => 108
//     [3] => 108
//     [4] => 111
// )
// 48 65 6C 6C 6F -- -- -- -- -- -- -- -- -- -- -- Hello

 


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