Description
JS_NewStringCopyN allocates space for a JS string and its underlying storage, and copies as many characters from a C character array, s , as possible, up to n bytes, into the new JS string. If the number of bytes in s is greater than the number of characters specified in n , the new JS string contains a truncated version of the original string. If the number of characters in s is less than the number of bytes specified in n , the new JS string is padded with nulls to the specified length.
You can use JS_NewStringCopyN to copy binary data, which may contain ASCII 0 characters. You can also use this function when you want to copy only a certain portion of a C string into a JS string.
If the allocation is successful, JS_NewStringCopyN returns a pointer to the JS string. Otherwise it returns NULL .
|