I am trying to convert a string to buffer using nodejs. The string is here :
\xf5\x89\xf8\x19+q@o\xa7\xdcwa2\x8f@\x0c\xd1\x14\x8bT6u@~a]HG\x83
When I am doing this from console, I get a simple buffer. But if I read that from a text file, the corresponding buffer results in a different way. I am working with the following code :
var data = '\xf5\x89\xf8\x19+q@o\xa7\xdcwa2\x8f@\x0c\xd1\x14\x8bT6u@~a]HG\x83';
const buf = Buffer.from(data, 'ascii'); // Converting string to buffer
console.log(buf);
// While reading from file
fs = require('fs')
fs.readFile('notes.txt', function (err,data) {
console.log(data);
});
Is it possible to get the same buffer in both way?