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] str:表示 ISO-8859-1 编码字符串的字符缓冲区。[in] length:字符串的字节长度,如果是以空字符结尾,则使用NAPI_AUTO_LENGTH。[out] result:一个napi_value,表示一个优化过的 JavaScriptstring,用作对象的属性键。
如果 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.】