node_api_create_property_key_latin1
napi_status NAPI_CDECL node_api_create_property_key_latin1(napi_env env,
const char* str,
size_t length,
napi_value* result); -
[in] env:调用 API 的环境。¥
[in] env: The environment that the API is invoked under. -
[in] str:表示 ISO-8859-1 编码字符串的字符缓冲区。¥
[in] str: Character buffer representing an ISO-8859-1-encoded string. -
[in] length:字符串的长度(以字节为单位),如果它以 null 结尾则为NAPI_AUTO_LENGTH。¥
[in] length: The length of the string in bytes, orNAPI_AUTO_LENGTHif it is null-terminated. -
[out] result:napi_value代表优化的 JavaScriptstring,用作对象的属性键。¥
[out] result: Anapi_valuerepresenting an optimized JavaScriptstringto be used as a property key for objects.
如果 API 成功,则返回 napi_ok。
¥Returns napi_ok if the API succeeded.
此 API 从 ISO-8859-1 编码的 C 字符串创建优化的 JavaScript string 值,以用作对象的属性键。复制原生字符串。与 napi_create_string_latin1 相比,使用相同 str 指针对此函数的后续调用可能会受益于创建请求的 napi_value 的加速,具体取决于引擎。
¥This API creates an optimized JavaScript string value from
an ISO-8859-1-encoded C string to be used as a property key for objects.
The native string is copied. In contrast with napi_create_string_latin1,
subsequent calls to this function with the same str pointer may benefit from a speedup
in the creation of the requested napi_value, depending on the engine.
JavaScript string 类型在 ECMAScript 语言规范的 字符串类型部分 中进行了描述。
¥The JavaScript string type is described in
Section string type of the ECMAScript Language Specification.