Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schulhof <gabriel.schulhof@intel.com>2020-09-23 22:44:47 +0300
committerMichael Dawson <mdawson@devrus.com>2020-09-26 00:06:24 +0300
commitb54dd8d91d451d54aea3b2148180d109ecd1897e (patch)
tree5d9db89cdac4a5e5e78dc6de55db56b97bfbb001 /doc/api/n-api.md
parent2089b558351341f4e257584590a8e65009b3af59 (diff)
doc: improve N-API string-to-native doc
Mention null termination handling in the string size accounting and string truncation. PR-URL: https://github.com/nodejs/node/pull/35322 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <midawson@redhat.com>
Diffstat (limited to 'doc/api/n-api.md')
-rw-r--r--doc/api/n-api.md15
1 files changed, 9 insertions, 6 deletions
diff --git a/doc/api/n-api.md b/doc/api/n-api.md
index 2c8566329f4..ec3790721d5 100644
--- a/doc/api/n-api.md
+++ b/doc/api/n-api.md
@@ -3080,9 +3080,10 @@ napi_status napi_get_value_string_latin1(napi_env env,
* `[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.
+ passed in, the length of the string in bytes and excluding the null terminator
+ is returned in `result`.
* `[in] bufsize`: Size of the destination buffer. When this value is
- insufficient, the returned string will be truncated.
+ insufficient, the returned string will be truncated and null-terminated.
* `[out] result`: Number of bytes copied into the buffer, excluding the null
terminator.
@@ -3109,9 +3110,10 @@ napi_status napi_get_value_string_utf8(napi_env env,
* `[in] env`: The environment that the API is invoked under.
* `[in] value`: `napi_value` representing JavaScript string.
* `[in] buf`: Buffer to write the UTF8-encoded string into. If `NULL` is passed
- in, the length of the string (in bytes) is returned.
+ in, the length of the string in bytes and excluding the null terminator is
+ returned in `result`.
* `[in] bufsize`: Size of the destination buffer. When this value is
- insufficient, the returned string will be truncated.
+ insufficient, the returned string will be truncated and null-terminated.
* `[out] result`: Number of bytes copied into the buffer, excluding the null
terminator.
@@ -3137,9 +3139,10 @@ napi_status napi_get_value_string_utf16(napi_env env,
* `[in] env`: The environment that the API is invoked under.
* `[in] value`: `napi_value` representing JavaScript string.
* `[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) is returned.
+ passed in, the length of the string in 2-byte code units and excluding the
+ null terminator is returned.
* `[in] bufsize`: Size of the destination buffer. When this value is
- insufficient, the returned string will be truncated.
+ insufficient, the returned string will be truncated and null-terminated.
* `[out] result`: Number of 2-byte code units copied into the buffer, excluding
the null terminator.