"Sputnik" help  
Sputnik Help
BinaryEncodeBHex(<binary>, [<maxLineLength>])

Description

Encodes a binary string to a BinHex 4.0 string.

Parameters

<binary> The binary string to be encoded to BinHex 4.0 format.
[<maxLineLength>] (Optional) The maximum line length for wrapping the resulting string. Defaults to -1 (no newlines).

Return Value

Success: Returns the BinHex 4.0 encoded string.
Failure: Returns an empty string.

Remarks

The BinaryEncodeBHex function converts a binary string to a BinHex 4.0 formatted string. BinHex 4.0 is a binary-to-text encoding format that was once used primarily for sending binary files through email attachments on the classic Mac OS platform. The algorithm efficiently encodes the data, including Run-Length Encoding (RLE) for compression during stretches of identical bytes. The optional parameter maxLineLength specifies the maximum line length for wrapping the resulting BinHex 4.0 string. Setting maxLineLength to -1 disables line wrapping.

Related

BinaryDecodeBHex

Example

Example of usage:

my $str = Bin('a' rr 'f', 'A' rr 'F', '0' rr '9');
my $encoded = BinaryEncodeBHex($str);
say $encoded;
my $decoded = BinaryDecodeBHex($encoded);
say $decoded;
// PRINTS
// !*!$&R,hB@*MC'9Q38*$4%9'-$%b-c3e0MFi1FYC
// abcdefABCDEF0123456789

 


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