cstrncpy
Works similarly to C's strncpy(3), copying, at most, n bytes (not characters) from srcPtr to tgtPtr. It copies until n bytes have been copied or a 0 byte is reached in src. Unlike strncpy(), it returns the number of bytes it assigns in tgtPtr, including the NUL byte (if any). If n is reached before a NUL byte in srcPtr, tgtPtr will not be NUL-terminated. If a NUL byte is reached before n bytes are copied, tgtPtr will be NUL-terminated.
If n is negative, cstrlen(srcPtr)+1 is used to calculate it, the +1 being for the NUL byte.
Throws if tgtPtr or srcPtr are falsy. Results are undefined if:
Either is not a pointer into the WASM heap or
srcPtr is not NUL-terminated AND n is less than srcPtr's logical length.
ACHTUNG: when passing in a non-negative n value, it is possible to copy partial multibyte characters this way, and converting such strings back to JS strings will have undefined results.