diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 0b8e7c6b976725..99c9c79d71d74d 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -149,8 +149,8 @@ changes: description: Removed the deprecated `raw` and `raws` encodings. --> -A character encoding may be specified when converting between a string and a -`Buffer`. +When string data is stored in or extracted out of a `Buffer` instance, a +character encoding may be specified. ```js const buf = Buffer.from('hello world', 'ascii'); @@ -159,6 +159,11 @@ console.log(buf.toString('hex')); // Prints: 68656c6c6f20776f726c64 console.log(buf.toString('base64')); // Prints: aGVsbG8gd29ybGQ= + +console.log(Buffer.from('fhqwhgads', 'ascii')); +// Prints: +console.log(Buffer.from('fhqwhgads', 'ucs2')); +// Prints: ``` The character encodings currently supported by Node.js include: