I am trying to read the contents of a properties file in node. this is my call:
fs.readFile("server/config.properties", {encoding: 'utf8'}, function(err, data ) {
console.log( data );
});
The console prints a buffer:
<Buffer 74 69 74 69 20 3d 20 74 6f 74 6f 0a 74 61 74 61 20 3d 20 74 75 74 75>
when I replace the code with this:
fs.readFile("server/config.properties", function(err, data ) {
console.log( data.toString('utf8') );
});
it works fine. But the node documentation says the String is converted to utf8 if the encoding is passed in the options
the output of node --version is v0.10.2
What am I missing here?
thank you for your support