Skip to content

Commit 2f87de9

Browse files
kfarnungMylesBorins
authored andcommitted
doc: added napi_get_value_string_latin1
* Reordered string functions alphabetically * Fixed a typo in napi_get_value_string_utf8 PR-URL: #14678 Fixes: #14397 Refs: #14256 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
1 parent 8004625 commit 2f87de9

File tree

1 file changed

+50
-23
lines changed

1 file changed

+50
-23
lines changed

doc/api/n-api.md

+50-23
Original file line numberDiff line numberDiff line change
@@ -1462,51 +1462,51 @@ The JavaScript Number type is described in
14621462
[Section 6.1.6](https://tc39.github.io/ecma262/#sec-ecmascript-language-types-number-type)
14631463
of the ECMAScript Language Specification.
14641464
1465-
#### *napi_create_string_utf16*
1465+
#### *napi_create_string_latin1*
14661466
<!-- YAML
14671467
added: v8.0.0
14681468
-->
14691469
```C
1470-
napi_status napi_create_string_utf16(napi_env env,
1471-
const char16_t* str,
1472-
size_t length,
1473-
napi_value* result)
1470+
NAPI_EXTERN napi_status napi_create_string_latin1(napi_env env,
1471+
const char* str,
1472+
size_t length,
1473+
napi_value* result);
14741474
```
14751475

14761476
- `[in] env`: The environment that the API is invoked under.
1477-
- `[in] str`: Character buffer representing a UTF16-LE-encoded string.
1478-
- `[in] length`: The length of the string in two-byte code units, or -1 if
1479-
it is null-terminated.
1477+
- `[in] str`: Character buffer representing a ISO-8859-1-encoded string.
1478+
- `[in] length`: The length of the string in bytes, or -1 if it is
1479+
null-terminated.
14801480
- `[out] result`: A `napi_value` representing a JavaScript String.
14811481

14821482
Returns `napi_ok` if the API succeeded.
14831483

1484-
This API creates a JavaScript String object from a UTF16-LE-encoded C string
1484+
This API creates a JavaScript String object from a ISO-8859-1-encoded C string.
14851485

14861486
The JavaScript String type is described in
14871487
[Section 6.1.4](https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type)
14881488
of the ECMAScript Language Specification.
14891489

1490-
#### *napi_create_string_latin1*
1490+
#### *napi_create_string_utf16*
14911491
<!-- YAML
14921492
added: v8.0.0
14931493
-->
14941494
```C
1495-
NAPI_EXTERN napi_status napi_create_string_latin1(napi_env env,
1496-
const char* str,
1497-
size_t length,
1498-
napi_value* result);
1495+
napi_status napi_create_string_utf16(napi_env env,
1496+
const char16_t* str,
1497+
size_t length,
1498+
napi_value* result)
14991499
```
15001500
15011501
- `[in] env`: The environment that the API is invoked under.
1502-
- `[in] str`: Character buffer representing a latin1-encoded string.
1503-
- `[in] length`: The length of the string in bytes, or -1 if it is
1504-
null-terminated.
1502+
- `[in] str`: Character buffer representing a UTF16-LE-encoded string.
1503+
- `[in] length`: The length of the string in two-byte code units, or -1 if
1504+
it is null-terminated.
15051505
- `[out] result`: A `napi_value` representing a JavaScript String.
15061506
15071507
Returns `napi_ok` if the API succeeded.
15081508
1509-
This API creates a JavaScript String object from a latin1-encoded C string.
1509+
This API creates a JavaScript String object from a UTF16-LE-encoded C string
15101510
15111511
The JavaScript String type is described in
15121512
[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`.
17951795
This API returns the C int64 primitive equivalent of the given
17961796
JavaScript Number
17971797
1798+
#### *napi_get_value_string_latin1*
1799+
<!-- YAML
1800+
added: v8.0.0
1801+
-->
1802+
```C
1803+
NAPI_EXTERN napi_status napi_get_value_string_latin1(napi_env env,
1804+
napi_value value,
1805+
char* buf,
1806+
size_t bufsize,
1807+
size_t* result)
1808+
```
1809+
1810+
- `[in] env`: The environment that the API is invoked under.
1811+
- `[in] value`: `napi_value` representing JavaScript string.
1812+
- `[in] buf`: Buffer to write the ISO-8859-1-encoded string into. If NULL is
1813+
passed in, the length of the string (in bytes) is returned.
1814+
- `[in] bufsize`: Size of the destination buffer.
1815+
- `[out] result`: Number of bytes copied into the buffer including the null
1816+
terminator. If the buffer size is insufficient, the string will be truncated
1817+
including a null terminator.
1818+
1819+
Returns `napi_ok` if the API succeeded. If a non-String `napi_value`
1820+
is passed in it returns `napi_string_expected`.
1821+
1822+
This API returns the ISO-8859-1-encoded string corresponding the value passed
1823+
in.
1824+
17981825
#### *napi_get_value_string_utf8*
17991826
<!-- YAML
18001827
added: v8.0.0
@@ -1810,14 +1837,14 @@ napi_status napi_get_value_string_utf8(napi_env env,
18101837
- `[in] env`: The environment that the API is invoked under.
18111838
- `[in] value`: `napi_value` representing JavaScript string.
18121839
- `[in] buf`: Buffer to write the UTF8-encoded string into. If NULL is passed
1813-
in, the length of the string (in bytes) is returned.
1840+
in, the length of the string (in bytes) is returned.
18141841
- `[in] bufsize`: Size of the destination buffer.
1815-
- `[out] result`: Number of bytes copied into the buffer including the null.
1842+
- `[out] result`: Number of bytes copied into the buffer including the null
18161843
terminator. If the buffer size is insufficient, the string will be truncated
18171844
including a null terminator.
18181845
1819-
Returns `napi_ok` if the API succeeded. Ifa non-String `napi_value`
1820-
x is passed in it returns `napi_string_expected`.
1846+
Returns `napi_ok` if the API succeeded. If a non-String `napi_value`
1847+
is passed in it returns `napi_string_expected`.
18211848
18221849
This API returns the UTF8-encoded string corresponding the value passed in.
18231850
@@ -1839,7 +1866,7 @@ napi_status napi_get_value_string_utf16(napi_env env,
18391866
passed in, the length of the string (in 2-byte code units) is returned.
18401867
- `[in] bufsize`: Size of the destination buffer.
18411868
- `[out] result`: Number of 2-byte code units copied into the buffer including
1842-
the null terminateor. If the buffer size is insufficient, the string will be
1869+
the null terminator. If the buffer size is insufficient, the string will be
18431870
truncated including a null terminator.
18441871

18451872
Returns `napi_ok` if the API succeeded. If a non-String `napi_value`

0 commit comments

Comments
 (0)