Buffer.alloc(8) // allocate 8 00bytes
Buffer.allocUnsafe(100) // allocate buffer with trash data
Buffer.allocUnsafe(100).fill() // fill allocated data
================
var str = "☕";
console.log(str.length);
console.log(Buffer.from(str).length);
================
const fs = require('fs');
const conversionMap = {
'88': '65',
'89': '66',
'90': '67'
};
fs.readFile(__filename,(err,buffer)=>{
let tag = buffer.slice(-3);
console.log(tag);
for(let i=0;i<tag.length;i++){
tag[i] = conversionMap[tag[i]];
}
console.log(buffer.toString());
});
// TAG: XYZ