"Sputnik" help  
Sputnik Help
BinaryWriteUtf8CString(<binary>, <position>, <value>)

Description

Writes a null-terminated UTF-8 encoded string to a binary string at the specified position. This function allows you to insert a string into a binary string, ensuring it is null-terminated.

Parameters

<binary> The binary string to write the UTF-8 encoded string into.
<position> The position at which to write the UTF-8 encoded string.
<value> The UTF-8 encoded string to be written.

Return Value

Success: Returns true if the write operation is successful.
Failure: Returns null if the position is invalid or out of bounds.

Remarks

The BinaryWriteUtf8CString function allows you to insert a null-terminated UTF-8 encoded string into a binary string. It ensures that the written string is properly terminated with a null character (0x00). If the position is invalid or out of bounds, the function will return null, indicating a failure.

Related

BinaryReadUtf8CString

Example

Example of usage:

my $a = BinNew(32);

BinaryWriteUtf8CString($a, 0, "Quick");
BinaryWriteUtf8CString($a, 8, "Brown");
BinaryWriteUtf8CString($a, 16, "Fox");

say BinaryExpand($a, false);

say BinaryReadUtf8CString($a, 0);
say BinaryReadUtf8CString($a, 8);
say BinaryReadUtf8CString($a, 16);

// PRINTS
// 51 75 69 63 6B 00 00 00 42 72 6F 77 6E 00 00 00 Quick...Brown...
// 46 6F 78 00 00 00 00 00 00 00 00 00 00 00 00 00 Fox.............
// Quick
// Brown
// Fox

 


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