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

Description

Reads a null-terminated UTF-16 encoded string from a binary string starting at the specified position. This function allows you to extract a string from a binary string, assuming it is null-terminated.

Parameters

<binary> The binary string to write the UTF-16 encoded string into.
<position> The position at which to write the UTF-16 encoded string.

Return Value

Success: Returns the extracted null-terminated UTF-16 encoded string, which may be a partial string if it encounters a null character (0x00) before the end.
Failure: Returns null if the position is invalid or out of bounds.

Remarks

The BinaryReadUtf16CString function allows you to extract a null-terminated UTF-16 encoded string from a binary string. It starts reading the string from the specified position until it encounters a null character (0x00) that marks the end of the string or reaches the end of the binary string. If the position is invalid or out of bounds, the function will return null, indicating a failure.

Related

BinaryWriteUtf16CString

Example

Example of usage:

my $a = BinNew(64);

BinaryWriteUtf16CString($a, 0, "Quick");
BinaryWriteUtf16CString($a, 16, "Brown");
BinaryWriteUtf16CString($a, 32, "Fox");

say BinaryExpand($a, false);

say BinaryReadUtf16CString($a, 0);
say BinaryReadUtf16CString($a, 16);
say BinaryReadUtf16CString($a, 32);

// PRINTS
// 51 00 75 00 69 00 63 00 6B 00 00 00 00 00 00 00 Q.u.i.c.k.......
// 42 00 72 00 6F 00 77 00 6E 00 00 00 00 00 00 00 B.r.o.w.n.......
// 46 00 6F 00 78 00 00 00 00 00 00 00 00 00 00 00 F.o.x...........
// Quick
// Brown
// Fox

 


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