-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Documentation mismatch for napi_get_value_string_* functions #14398
Comments
It's a doc issue. I think the doc was originally written when there were separate APIs for getting the string length vs string contents, and then it was not updated correctly when the APIs were redesigned. The string APIs now are intentionally designed so they can be used to just get the string length (not including null terminator) by passing in a null buffer. So even when you do provide a buffer, the returned value, which is the number of characters copied, does not include the null terminator for consistency. |
Yup, I agree it's more convenient that way, just wanted to know whether it's docs or implementation that got out of sync. By the way, is there a specific reason this API is not aligned with Given what you said, I suspect the reason was exactly that one referred to initial length excluding null, while the other returned total size of written bytes, but now that in/out have the same meaning, would it be reasonable to align these APIs for consistency? (I can raise a separate issue for that) |
The |
Makes sense I guess... |
hello! i'm a first-time contributor, and it seems that the issue highlights a change needed in the is it okay if I open a PR for this change? |
@taveras Absolutely :) |
The API for napi_get_value_string_utf8() appears to have been previously changed. This improves the doc reflect the current design. PR-URL: nodejs/node#14529 Fixes: nodejs/node#14398 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
The API for napi_get_value_string_utf8() appears to have been previously changed. This improves the doc reflect the current design. PR-URL: nodejs/node#14529 Fixes: nodejs/node#14398 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
The API for napi_get_value_string_utf8() appears to have been previously changed. This improves the doc reflect the current design. PR-URL: #14529 Fixes: #14398 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
The API for napi_get_value_string_utf8() appears to have been previously changed. This improves the doc reflect the current design. PR-URL: #14529 Fixes: #14398 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
The API for napi_get_value_string_utf8() appears to have been previously changed. This improves the doc reflect the current design. PR-URL: nodejs#14529 Fixes: nodejs#14398 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
The API for napi_get_value_string_utf8() appears to have been previously changed. This improves the doc reflect the current design. Backport-PR-URL: #19447 PR-URL: #14529 Fixes: #14398 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
napi_get_value_string_*
say e.g.:However, the actual implementation in Node returns the number of bytes excluding the null terminator (so for an empty string, it will return
0
and not1
).Not sure if it's implementation or documentation issue, or I was just confused by the wording. cc @nodejs/n-api
The text was updated successfully, but these errors were encountered: