From 9428304d4a829ae9f7bb49c21faaed1ea3289c14 Mon Sep 17 00:00:00 2001 From: Jan-Philip Gehrcke Date: Thu, 28 Nov 2019 19:30:52 +0100 Subject: [PATCH] doc: Buffer.toString(): add note about invalid data PR-URL: https://github.com/nodejs/node/pull/30706 Reviewed-By: Anna Henningsen Reviewed-By: Denys Otrishko Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: David Carlier --- doc/api/buffer.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index a97ab6c2a6314b..c5b7bf15047177 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -2162,6 +2162,8 @@ added: v0.1.90 Decodes `buf` to a string according to the specified character encoding in `encoding`. `start` and `end` may be passed to decode only a subset of `buf`. +If a byte sequence in the input is not valid in the given `encoding` then +it is replaced with the replacement character `U+FFFD`. The maximum length of a string instance (in UTF-16 code units) is available as [`buffer.constants.MAX_STRING_LENGTH`][].