What encodings does Buffer.toString () support?

I am writing an application in node.js and see that I can do such things:

var buf = new Buffer("Hello World!") console.log(buf.toString("hex")) console.log(buf.toString("utf8")) 

And I know about ascii as an encoding type (it will take ASCII code like 112 and turn it into p ), but what other types of encoding can I do?

+6
source share
3 answers

The official node.js documentation for Buffer is the best place to check for something like this. As already noted, Buffer currently supports these encodings: ascii , utf8 , utf16le / ucs2 , base64 , binary and hex .

+5
source

As always, I spent some time on Google, but did not find anything until I posted a question:

http://www.w3resource.com/node.js/nodejs-buffer.php has an answer. You can use the following types in .toString() in the buffer:

  • ascii
  • utf8
  • utf16le
  • ucs2 (alias utf16le )
  • base64
  • binary
  • hex
+4
source

It supports ascii , utf-8 , ucs2, base64, binary

0
source

All Articles