Friday, 17 March 2017

What encoding does Javascript fs.readFileSync return?

Consider the following Node.js Javascript program:

var fs = require('fs');
var encoding='utf8';
var a = fs.readFileSync('./testdoc.pdf');
var b = new Buffer(fs.readFileSync('./testdoc.pdf',encoding));
console.log(a===b);

To what value must the encoding variable be set in order for true to be printed at the console?



via David Powell

No comments:

Post a Comment