1
I’m learning a little bit about NodeJS
. The last thing I learned was reading a file.
The question that left me doubtful is the following. When I use the function readFile
with the second parameter being utf8
, the reading of the file occurs in an expected way (the same way that occurs in PHP, the language I come from).
Example:
var fs = require('fs')
fs.readFile('files/text.txt', 'utf8', function (err, data) {
console.log(data)
});
However, when I don’t pass the argument indicating that the reading will be like utf8
, things change:
fs.readFile('files/text.txt', function (err, data)
{
console.log(data)
});
Exit:
<Buffer 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 20 61 64 69 70 69 73 69 63 69 6e 67 ...>
What is the meaning of this <Buffer>
?