"Sputnik" help  
Sputnik Help
BinaryPadCenter(<binary>, <totalWidth>, <paddingByte>)


The BinaryPadCenter function is used to pad a binary string on the left and right side with a specified padding byte, resulting in a binary string with a specified total width.


<binary> The original binary string to be padded.
<totalWidth> The desired total width of the resulting binary string.
<paddingByte> Optional byte used for padding. If not specified, the default padding byte is 0x20 (space).

Return Value

Success: Returns a new binary string with the specified total width, padded on the left and right side.
Failure: Returns an empty binary string.


If the <binary> string is already equal to or longer than the <totalWidth>, the function will return the original binary string unchanged.
The <paddingByte> is used to fill the space on the left and right side of the <binary> string to achieve the desired <totalWidth>. It can be any byte value, but the default padding byte is 0x20 (space).
The resulting binary string will have a length equal to <totalWidth>. If the <binary> string is shorter than <totalWidth>, the remaining space will be filled with the specified <paddingByte>.
The original binary string is not modified; instead, a new binary string is created with the padding applied.


BinaryPadRight, BinaryPad


Example of usage:

my $binary = BinaryFromStr("Hello");
my $paddedBoth = BinaryPad($binary, 10, @PaddingBoth);
my $paddedStart = BinaryPadLeft($binary, 10);
my $paddedEnd = BinaryPadRight($binary, 10);
my $paddedCenter = BinaryPadCenter($binary, 10);
say "'$paddedBoth'";
say "'$paddedStart'";
say "'$paddedEnd'";
say "'$paddedCenter'";

// '          Hello          '
// '     Hello'
// 'Hello     '
// '  Hello   '


Cheryl (uberfox@hotmail.com)