Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', null-terminated and encoded in UTF8 form. The copy will require at most str.length*4+1 bytes of space in the HEAP. Use the function lengthBytesUTF8() to compute the exact number of bytes (excluding null terminator) that this function will write. Returns the number of bytes written, EXCLUDING the null terminator.
function stringToUTF8(str, outPtr, maxBytesToWrite) {
  assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
  return stringToUTF8Array(str, HEAPU8,outPtr, maxBytesToWrite);
}