doc: clarify the behavior of Buffer.byteLength

PR-URL: https://github.com/nodejs/node/pull/11238
Refs: https://github.com/nodejs/node/issues/11165
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
Nikolai Vavilov 2017-02-09 20:47:48 +02:00 committed by GitHub
parent 0700927832
commit 271d50a892

View File

@ -618,6 +618,10 @@ Returns the actual byte length of a string. This is not the same as
[`String.prototype.length`] since that returns the number of *characters* in [`String.prototype.length`] since that returns the number of *characters* in
a string. a string.
*Note* that for `'base64'` and `'hex'`, this function assumes valid input. For
strings that contain non-Base64/Hex-encoded data (e.g. whitespace), the return
value might be greater than the length of a `Buffer` created from the string.
Example: Example:
```js ```js