diff --git a/doc/api/buffer.md b/doc/api/buffer.md index b551f72ad98029..99c9c79d71d74d 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -149,10 +149,8 @@ changes: description: Removed the deprecated `raw` and `raws` encodings. --> -`Buffer` instances are commonly used to represent sequences of encoded characters -such as UTF-8, UCS2, Base64, or even Hex-encoded data. It is possible to -convert back and forth between `Buffer` instances and ordinary JavaScript strings -by using an explicit character encoding. +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'); @@ -161,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: