From e1e02efac569824a5fb893751539f33cf622be18 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 7035fa254e77d9..e90d2f2616f8bd 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -528,6 +528,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