diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 109674a4bf4..4397af96898 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -1462,6 +1462,31 @@ The JavaScript Number type is described in [Section 6.1.6](https://tc39.github.io/ecma262/#sec-ecmascript-language-types-number-type) of the ECMAScript Language Specification. +#### *napi_create_string_latin1* + +```C +NAPI_EXTERN napi_status napi_create_string_latin1(napi_env env, + const char* str, + size_t length, + napi_value* result); +``` + +- `[in] env`: The environment that the API is invoked under. +- `[in] str`: Character buffer representing a ISO-8859-1-encoded string. +- `[in] length`: The length of the string in bytes, or -1 if it is +null-terminated. +- `[out] result`: A `napi_value` representing a JavaScript String. + +Returns `napi_ok` if the API succeeded. + +This API creates a JavaScript String object from a ISO-8859-1-encoded C string. + +The JavaScript String type is described in +[Section 6.1.4](https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type) +of the ECMAScript Language Specification. + #### *napi_create_string_utf16* -```C -NAPI_EXTERN napi_status napi_create_string_latin1(napi_env env, - const char* str, - size_t length, - napi_value* result); -``` - -- `[in] env`: The environment that the API is invoked under. -- `[in] str`: Character buffer representing a latin1-encoded string. -- `[in] length`: The length of the string in bytes, or -1 if it is -null-terminated. -- `[out] result`: A `napi_value` representing a JavaScript String. - -Returns `napi_ok` if the API succeeded. - -This API creates a JavaScript String object from a latin1-encoded C string. - -The JavaScript String type is described in -[Section 6.1.4](https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type) -of the ECMAScript Language Specification. - #### *napi_create_string_utf8* +```C +NAPI_EXTERN napi_status napi_get_value_string_latin1(napi_env env, + napi_value value, + char* buf, + size_t bufsize, + size_t* result) +``` + +- `[in] env`: The environment that the API is invoked under. +- `[in] value`: `napi_value` representing JavaScript string. +- `[in] buf`: Buffer to write the ISO-8859-1-encoded string into. If NULL is +passed in, the length of the string (in bytes) is returned. +- `[in] bufsize`: Size of the destination buffer. +- `[out] result`: Number of bytes copied into the buffer including the null +terminator. If the buffer size is insufficient, the string will be truncated +including a null terminator. + +Returns `napi_ok` if the API succeeded. If a non-String `napi_value` +is passed in it returns `napi_string_expected`. + +This API returns the ISO-8859-1-encoded string corresponding the value passed +in. + #### *napi_get_value_string_utf8*