Skip to content
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

n-api: remove napi_get_value_string_length() #12496

Closed
wants to merge 1 commit into from

Commits on Apr 18, 2017

  1. n-api: remove napi_get_value_string_length()

    This API doesn't serve much purpose, and is only likely to cause
    confusion and bugs. The intention was that this would return the
    number of characters in a string independent of encoding, but
    that's not generally useful. In almost all cases, one of the
    encoding-specific napi_get_value_string_* APIs is more correct.
    (Pass a null buffer if only the encoded length is desired.)
    
    Anyway the current implementation of napi_get_value_string_length()
    is technically wrong: it returns the number of 2-byte code units of
    the UTF-16 encoding, but there are actually some characters that
    are encoded as two UTF-16 code units.
    
    Note the JavaScript String.prototype.length property returns the
    number of UTF-16 code units, which may be different from the number
    of characters. So, getting the true character count is not common
    with JavaScript, and is probably best left to specialized
    internationalization libraries.
    
    Fixes: nodejs/abi-stable-node#226
    jasongin committed Apr 18, 2017
    Configuration menu
    Copy the full SHA
    0fac7cd View commit details
    Browse the repository at this point in the history