Browse Source

doc: added napi_get_value_string_latin1

* Reordered string functions alphabetically
* Fixed a typo in napi_get_value_string_utf8

PR-URL: https://github.com/nodejs/node/pull/14678
Fixes: https://github.com/nodejs/node/issues/14397
Refs: https://github.com/nodejs/node/issues/14256
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
canary-base
Kyle Farnung 8 years ago
committed by Tobias Nießen
parent
commit
e96b94970a
  1. 73
      doc/api/n-api.md

73
doc/api/n-api.md

@ -1462,51 +1462,51 @@ The JavaScript Number type is described in
[Section 6.1.6](https://tc39.github.io/ecma262/#sec-ecmascript-language-types-number-type) [Section 6.1.6](https://tc39.github.io/ecma262/#sec-ecmascript-language-types-number-type)
of the ECMAScript Language Specification. of the ECMAScript Language Specification.
#### *napi_create_string_utf16* #### *napi_create_string_latin1*
<!-- YAML <!-- YAML
added: v8.0.0 added: v8.0.0
--> -->
```C ```C
napi_status napi_create_string_utf16(napi_env env, NAPI_EXTERN napi_status napi_create_string_latin1(napi_env env,
const char16_t* str, const char* str,
size_t length, size_t length,
napi_value* result) napi_value* result);
``` ```
- `[in] env`: The environment that the API is invoked under. - `[in] env`: The environment that the API is invoked under.
- `[in] str`: Character buffer representing a UTF16-LE-encoded string. - `[in] str`: Character buffer representing a ISO-8859-1-encoded string.
- `[in] length`: The length of the string in two-byte code units, or -1 if - `[in] length`: The length of the string in bytes, or -1 if it is
it is null-terminated. null-terminated.
- `[out] result`: A `napi_value` representing a JavaScript String. - `[out] result`: A `napi_value` representing a JavaScript String.
Returns `napi_ok` if the API succeeded. Returns `napi_ok` if the API succeeded.
This API creates a JavaScript String object from a UTF16-LE-encoded C string This API creates a JavaScript String object from a ISO-8859-1-encoded C string.
The JavaScript String type is described in The JavaScript String type is described in
[Section 6.1.4](https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type) [Section 6.1.4](https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type)
of the ECMAScript Language Specification. of the ECMAScript Language Specification.
#### *napi_create_string_latin1* #### *napi_create_string_utf16*
<!-- YAML <!-- YAML
added: v8.0.0 added: v8.0.0
--> -->
```C ```C
NAPI_EXTERN napi_status napi_create_string_latin1(napi_env env, napi_status napi_create_string_utf16(napi_env env,
const char* str, const char16_t* str,
size_t length, size_t length,
napi_value* result); napi_value* result)
``` ```
- `[in] env`: The environment that the API is invoked under. - `[in] env`: The environment that the API is invoked under.
- `[in] str`: Character buffer representing a latin1-encoded string. - `[in] str`: Character buffer representing a UTF16-LE-encoded string.
- `[in] length`: The length of the string in bytes, or -1 if it is - `[in] length`: The length of the string in two-byte code units, or -1 if
null-terminated. it is null-terminated.
- `[out] result`: A `napi_value` representing a JavaScript String. - `[out] result`: A `napi_value` representing a JavaScript String.
Returns `napi_ok` if the API succeeded. Returns `napi_ok` if the API succeeded.
This API creates a JavaScript String object from a latin1-encoded C string. This API creates a JavaScript String object from a UTF16-LE-encoded C string
The JavaScript String type is described in The JavaScript String type is described in
[Section 6.1.4](https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type) [Section 6.1.4](https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type)
@ -1795,6 +1795,33 @@ is passed in it returns `napi_number_expected`.
This API returns the C int64 primitive equivalent of the given This API returns the C int64 primitive equivalent of the given
JavaScript Number JavaScript Number
#### *napi_get_value_string_latin1*
<!-- YAML
added: v8.0.0
-->
```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* #### *napi_get_value_string_utf8*
<!-- YAML <!-- YAML
added: v8.0.0 added: v8.0.0
@ -1810,14 +1837,14 @@ napi_status napi_get_value_string_utf8(napi_env env,
- `[in] env`: The environment that the API is invoked under. - `[in] env`: The environment that the API is invoked under.
- `[in] value`: `napi_value` representing JavaScript string. - `[in] value`: `napi_value` representing JavaScript string.
- `[in] buf`: Buffer to write the UTF8-encoded string into. If NULL is passed - `[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) is returned.
- `[in] bufsize`: Size of the destination buffer. - `[in] bufsize`: Size of the destination buffer.
- `[out] result`: Number of bytes copied into the buffer including the null. - `[out] result`: Number of bytes copied into the buffer including the null
terminator. If the buffer size is insufficient, the string will be truncated terminator. If the buffer size is insufficient, the string will be truncated
including a null terminator. including a null terminator.
Returns `napi_ok` if the API succeeded. Ifa non-String `napi_value` Returns `napi_ok` if the API succeeded. If a non-String `napi_value`
x is passed in it returns `napi_string_expected`. is passed in it returns `napi_string_expected`.
This API returns the UTF8-encoded string corresponding the value passed in. This API returns the UTF8-encoded string corresponding the value passed in.
@ -1839,7 +1866,7 @@ napi_status napi_get_value_string_utf16(napi_env env,
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) is returned.
- `[in] bufsize`: Size of the destination buffer. - `[in] bufsize`: Size of the destination buffer.
- `[out] result`: Number of 2-byte code units copied into the buffer including - `[out] result`: Number of 2-byte code units copied into the buffer including
the null terminateor. If the buffer size is insufficient, the string will be the null terminator. If the buffer size is insufficient, the string will be
truncated including a null terminator. truncated including a null terminator.
Returns `napi_ok` if the API succeeded. If a non-String `napi_value` Returns `napi_ok` if the API succeeded. If a non-String `napi_value`

Loading…
Cancel
Save