From 8a078c820e113ea48c89f885d08e6de25a56c27c Mon Sep 17 00:00:00 2001 From: Nikolai Vavilov Date: Thu, 9 Feb 2017 20:47:48 +0200 Subject: [PATCH] doc: clarify the behavior of Buffer.byteLength MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/11238 Refs: https://github.com/nodejs/node/issues/11165 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso --- doc/api/buffer.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 8cb5c94a40b5e8..43623e16e56edc 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -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 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: ```js