"Sputnik" help  
Sputnik Help
BinaryReadCString(<binary>, <position>)

Description

Reads a C-style string from a binary array starting from the specified position.

Parameters

<binary> The binary array from which to read the string.
<position> The position in the binary array to start reading from.

Return Value

Success: Returns the C-style string.
Failure: Returns null.

Remarks

The BinaryReadCString function reads bytes from the binary array one by one until it encounters a null terminator (byte value 0) or reaches the end of the array. It builds the resulting string by appending each byte as a character.

Related

BinaryWriteCString

Example

Example of usage:

my $a = BinNew(64);

BinaryWriteCString($a, 0, "Cat");
BinaryWriteCString($a, 4, "Dog");
BinaryWriteCString($a, 8, "Fox");

say BinaryExpand($a, false);

say BinaryReadCString($a, 0);
say BinaryReadCString($a, 4);
say BinaryReadCString($a, 8);

// PRINTS
// 43 61 74 00 44 6F 67 00 46 6F 78 00 00 00 00 00 Cat.Dog.Fox.....
// Cat
// Dog
// Fox

 


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