napi_get_value_string_utf16


napi_status napi_get_value_string_utf16(napi_env env,
                                        napi_value value,
                                        char16_t* buf,
                                        size_t bufsize,
                                        size_t* result) 
  • [in] env:调用 API 的环境。

    ¥[in] env: The environment that the API is invoked under.

  • [in] valuenapi_value 代表 JavaScript 字符串。

    ¥[in] value: napi_value representing JavaScript string.

  • [in] buf:将 UTF16-LE 编码字符串写入的缓冲区。如果传入 NULL,则返回字符串的 2 字节代码单元长度,不包括空终止符。

    ¥[in] buf: Buffer to write the UTF16-LE-encoded string into. If NULL is passed in, the length of the string in 2-byte code units and excluding the null terminator is returned.

  • [in] bufsize:目标缓冲区的大小。当此值不足时,返回的字符串将被截断并以 null 终止。

    ¥[in] bufsize: Size of the destination buffer. When this value is insufficient, the returned string is truncated and null-terminated.

  • [out] result:复制到缓冲区中的 2 字节代码单元数,不包括空终止符。

    ¥[out] result: Number of 2-byte code units copied into the buffer, excluding the null terminator.

如果 API 成功,则返回 napi_ok。如果传入非 string napi_value,则返回 napi_string_expected

¥Returns napi_ok if the API succeeded. If a non-string napi_value is passed in it returns napi_string_expected.

此 API 返回对应于传入值的 UTF16 编码字符串。

¥This API returns the UTF16-encoded string corresponding the value passed in.