Skip to main content

napi_create_external_string_ascii

Function napi_create_external_string_ascii 

Source
pub unsafe extern "C" fn napi_create_external_string_ascii(
    env: napi_env,
    str_: *const c_char,
    length: usize,
    finalize_callback: napi_finalize_callback,
    finalize_hint: *mut c_void,
    result: *mut napi_value,
) -> napi_status
Available on crate features napi and api-22 only.
Expand description

Creates an ArkTS string from a ASCII-encoded C string.

§Arguments

  • env - Current running virtual machine context.

  • str - C string encoded in ASCII format.

  • length - The length of the C string ‘str’.

  • finalize_callback - Native finalize callback used to recycle native resource.

  • finalize_hint - Optional contextual hint that is passed to the finalize_callback.

  • result - Result of the ArkTS string from the ASCII-encoded C string.

§Returns

  • Returns the function execution status. [napi_ok] If the function executed successfully.

[napi_invalid_arg] If the param env, str and(or) result is nullptr;

If the param length is not equal with NAPI_AUTO_LENGTH and

length is larger than INT_MAX;

Available since API-level: 22