jstrcpy
Encodes the given JS string as UTF-8 into the given TypedArray tgt (which must be a Int8Array or Uint8Array), starting at the given offset and writing, at most, maxBytes bytes (including the NUL terminator if addNul is true, else no NUL is added). If it writes any bytes at all and addNul is true, it always NUL-terminates the output, even if doing so means that the NUL byte is all that it writes.
If maxBytes is negative (the default) then it is treated as the remaining length of tgt, starting at the given offset.
If writing the last character would surpass the maxBytes count because the character is multi-byte, that character will not be written (as opposed to writing a truncated multi-byte character). This can lead to it writing as many as 3 fewer bytes than maxBytes specifies.
Returns the number of bytes written to the target, including the NUL terminator (if any). If it returns 0, it wrote nothing at all, which can happen if:
jsString is empty and addNul is false.
offset < 0.
maxBytes === 0.
maxBytes is less than the byte length of a multi-byte jsString0.
Throws if tgt is not an Int8Array or Uint8Array.