"Sputnik" help  
Sputnik Help
BinaryReadBytes(<binary>, <position>, <size>)

Description

Reads a specified number of bytes from a binary string starting at the specified position.

Parameters

<binary> The binary string from which the bytes will be read.
<position> The position in the binary string to start reading from.
<size> The number of bytes to read.

Return Value

Success: Returns a binary string containing the bytes read from the binary string.
Failure: Returns null if the position is out of bounds or an error occurs during reading.

Remarks

The BinaryReadBytes function reads a specified number of bytes from the binary string starting at the specified position. It returns a string containing the bytes read from the binary string. The function checks if the position is within the bounds of the binary string and if there are enough bytes available to read. If the position is out of bounds or an error occurs during reading, it returns null.

Related

BinaryWriteBytes

Example

Example of usage:

my $a = BinNew(16);

BinaryWriteBytes($a, 0, Tb("CAT."));
BinaryWriteBytes($a, 4, Tb("DOG."));
BinaryWriteBytes($a, 8, Tb("FOX."));

say BinaryExpand($a, false);

if (@IsLittlEendian)
{
    say Bt(BinaryReadBytes($a, 0, 4)[::-1]);
    say Bt(BinaryReadBytes($a, 4, 4)[::-1]);
    say Bt(BinaryReadBytes($a, 8, 4)[::-1]);
}
else
{
    say Bt(BinaryReadBytes($a, 0, 4));
    say Bt(BinaryReadBytes($a, 4, 4));
    say Bt(BinaryReadBytes($a, 8, 4));
}

// PRINTS
// 2E 54 41 43 2E 47 4F 44 2E 58 4F 46 00 00 00 00 .TAC.GOD.XOF....
// CAT.
// DOG.
// FOX.

 


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