string_pack() function
Pack a NUL-terminated C string and return the number of bytes written. The output includes a length delimiter. The NULL pointer is treated as an empty string. This isn't really necessary, but it allows people to leave required strings blank. (See Issue #13 in the bug tracker for a little more explanation).
Syntax
static inline size_t
string_pack(const char *str,
uint8_t *out);
Return value
Number of bytes written to `out`.