doc: added napi_get_value_string_latin1#14678
doc: added napi_get_value_string_latin1#14678kfarnung wants to merge 2 commits intonodejs:masterfrom
Conversation
* Reordered string functions alphabetically * Fixed a typo in napi_get_value_string_utf8
cjihrig
left a comment
There was a problem hiding this comment.
LGTM. I have a question though. What is the motivation for truncating instead of returning something like ENOBUFS in napi_get_value_string_latin1(). Is there ever a case where the truncated value is preferred?
|
@cjihrig I'll let others say for sure, but from what I've seen this is consistent behavior with other string APIs (including the V8 ones). Admittedly I've gone back and forth myself as to whether it's the right behavior, but it seems pretty common. |
doc/api/n-api.md
Outdated
| - `[in] str`: Character buffer representing a UTF16-LE-encoded string. | ||
| - `[in] length`: The length of the string in two-byte code units, or -1 if | ||
| it is null-terminated. | ||
| - `[in] str`: Character buffer representing a latin1-encoded string. |
There was a problem hiding this comment.
Nit: I’d spell it as Latin-1 and/or say that it’s ISO-8859-1, I think most developers know it under that latter name.
|
Thanks @addaleax, I noticed a couple more typos and fixed them as well. |
TimothyGu
left a comment
There was a problem hiding this comment.
This suggestion only applies to V8. If this isn't the case for other supported VMs
then I'm happy for this PR to be landed as is.
| 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. |
There was a problem hiding this comment.
For V8 at least, the text doesn't have to be ISO-8859-1. "String encoded using a one-byte encoding" is perhaps more accurate.
There was a problem hiding this comment.
@TimothyGu huh? V8 does interpret that string as ISO-8859-1. We do use the …OneByte… methods in core for that encoding, and that’s what the V8 docs say (which, granted, I wrote, but also did pass review. 😄).
|
Landed in e96b949. |
* Reordered string functions alphabetically * Fixed a typo in napi_get_value_string_utf8 PR-URL: #14678 Fixes: #14397 Refs: #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>
* Reordered string functions alphabetically * Fixed a typo in napi_get_value_string_utf8 PR-URL: nodejs/node#14678 Fixes: nodejs/node#14397 Refs: nodejs/node#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>
* Reordered string functions alphabetically * Fixed a typo in napi_get_value_string_utf8 PR-URL: #14678 Fixes: #14397 Refs: #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>
* Reordered string functions alphabetically * Fixed a typo in napi_get_value_string_utf8 PR-URL: #14678 Fixes: #14397 Refs: #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>
* Reordered string functions alphabetically * Fixed a typo in napi_get_value_string_utf8 PR-URL: nodejs#14678 Fixes: nodejs#14397 Refs: nodejs#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>
* Reordered string functions alphabetically * Fixed a typo in napi_get_value_string_utf8 Backport-PR-URL: #19447 PR-URL: #14678 Fixes: #14397 Refs: #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>
Ref: #14256
Fixes: #14397
Checklist
Affected core subsystem(s)
doc, n-api