The official node.js documentation for Buffer is the best place to check for something like this. As previously noted, Buffer currently supports these encodings: 'ascii', 'utf8', 'utf16le'/'ucs2', 'base64', 'base64url', 'latin1'/'binary', and 'hex'.
W3Schools
w3schools.com › nodejs › met_buffer_tostring.asp
Node.js buffer toString() Method
The toString() method returns the buffer object according to the specified encoding.
W3schools-fa
w3schools-fa.ir › nodejs › met_buffer_tostring.html
Node.js buffer toString() Method
The toString() method returns the buffer object according to the specified encoding.
Top answer 1 of 3
66
The official node.js documentation for Buffer is the best place to check for something like this. As previously noted, Buffer currently supports these encodings: 'ascii', 'utf8', 'utf16le'/'ucs2', 'base64', 'base64url', 'latin1'/'binary', and 'hex'.
2 of 3
23
As is always the way, I spent a while Googling but found nothing until after I posted the question:
http://www.w3resource.com/node.js/nodejs-buffer.php has the answer. You can use the following types in .toString() on a buffer:
asciiutf8utf16leucs2(alias ofutf16le)base64binaryhex
Node.js
nodejs.org › api › buffer.html
Buffer | Node.js v26.10.0 Documentation
Empty value (string, Uint8Array, Buffer) is coerced to 0. offset <integer> Number of bytes to skip before starting to fill buf. Default: 0. end <integer> Where to stop filling buf (not inclusive). Default: buf.length. encoding <string> The encoding for value if value is a string.
Educative
educative.io › answers › what-is-the-nodejs-buffertostring-method
What is the Node.js Buffer.toString() method?
The encodings supported by Node.js include utf8, utf16le, and latin1. ... start: This references the beginning data of the buffer. It starts from 0, meaning that the first data starts from 0. The default value is 0. ... The default value is ...
W3Schools
w3schools.com › nodejs › nodejs_buffer.asp
Node.js Buffer Module
// Create a string const str = 'Hello, World!'; // Convert to different encodings const utf8Buffer = Buffer.from(str, 'utf8'); console.log('UTF-8:', utf8Buffer); const base64Str = utf8Buffer.toString('base64'); console.log('Base64 string:', base64Str); const hexStr = utf8Buffer.toString('hex'); console.log('Hex string:', hexStr); // Convert back to original const fromBase64 = Buffer.from(base64Str, 'base64').toString('utf8'); console.log('From Base64:', fromBase64); const fromHex = Buffer.from(hexStr, 'hex').toString('utf8'); console.log('From Hex:', fromHex); Run example »
Mastering JS
masteringjs.io › tutorials › node › buffer-to-string
Using the Buffer `toString()` Function in Node.js - Mastering JS
August 21, 2020 - By default, toString() converts the buffer to a string using UTF8 encoding.
W3Schools
w3schools.com › nodejs › met_buffer_from.asp
Node.js Buffer.from() Method
The Buffer.from() method creates a new buffer filled with the specified string, array, or buffer. Buffer.from(obj, encoding); ❮ Buffer Module · ★ +1 · Sign in to track progress · REMOVE ADS · Learn more about Adventure Mode› · Free ...
Readthedocs
node.readthedocs.io › en › latest › api › buffer
Buffer - node - Read the Docs
Converting between Buffers and JavaScript string objects requires an explicit encoding method.
W3Schools
w3schools.com › nodejs › met_buffer_isencoding.asp
Node.js Buffer.isEncoding() Method
Check if the Buffer supports the utf8 encoding: console.log(Buffer.isEncoding('windows-1252')); Run example » · ❮ Buffer Module · ★ +1 · Sign in to track progress · REMOVE ADS · PLUS · SPACES · GET CERTIFIED · FOR TEACHERS · BOOTCAMPS · CONTACT US ·
W3Schools
w3schools.com › nodejs › met_buffer_write.asp
Node.js buffer write() Method
let buf = Buffer.from('abcdef'); buf.write('qq', 2); console.log(buf.toString()); Run example » · The write() method writes the specified string into a buffer, at the specified position. buffer.write(value, start, bytes, encoding); ❮ Buffer ...
University of New Brunswick
cs.unb.ca › ~bremner › teaching › cs2613 › books › nodejs-api › buffer
buffer
Many web pages and other document formats use UTF-8. This is the default character encoding. When decoding a Buffer into a string that does not exclusively contain valid UTF-8 data, the Unicode replacement character U+FFFD � will be used to represent those errors.
TutorialsPoint
tutorialspoint.com › nodejs › nodejs_buffers.htm
Node.js - Buffers
Default: 'utf8'. The encoding parameter identifies the character encoding to be used when converting string into bytes. const buf1 = Buffer.from('Hello World'); console.log(buf1); console.log(buf1.toString());