-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: added napi_get_value_string_latin1 #14678
Conversation
* Reordered string functions alphabetically * Fixed a typo in napi_get_value_string_utf8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
- `[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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 <[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]>
* 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 <[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]>
* 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]>
* 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]>
* 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 <[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]>
* 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 <[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]>
Ref: #14256
Fixes: #14397
Checklist
Affected core subsystem(s)
doc, n-api