node_api_create_external_string_utf16
functionv10js_native_api.hThis API creates a JavaScript string value from a UTF16-LE-encoded C string. The native string may not be copied and must thus exist for the entire life cycle of the JavaScript value.
napi_status
node_api_create_external_string_utf16(napi_env env,
char16_t* str,
size_t length,
napi_finalize finalize_callback,
void* finalize_hint,
napi_value* result,
bool* copied);
[in] env: The environment that the API is invoked under.[in] str: Character buffer representing a UTF16-LE-encoded string.[in] length: The length of the string in two-byte code units, orNAPI_AUTO_LENGTHif it is null-terminated.[in] finalize_callback: The function to call when the string is being collected. The function will be called with the following parameters:[in] env: The environment in which the add-on is running. This value may be null if the string is being collected as part of the termination of the worker or the main Node.js instance.[in] data: This is the valuestras avoid*pointer.[in] finalize_hint: This is the valuefinalize_hintthat was given to the API.napi_finalizeprovides more details. This parameter is optional. Passing a null value means that the add-on doesn't need to be notified when the corresponding JavaScript string is collected.
[in] finalize_hint: Optional hint to pass to the finalize callback during collection.[out] result: Anapi_valuerepresenting a JavaScriptstring.[out] copied: Whether the string was copied. If it was, the finalizer will already have been invoked to destroystr.
Returns napi_ok if the API succeeded.
This API creates a JavaScript string value from a UTF16-LE-encoded C string.
The native string may not be copied and must thus exist for the entire life
cycle of the JavaScript value.
The JavaScript string type is described in
Section string type of the ECMAScript Language Specification.