I need to create a flat file with a string that contains hexadecimal and mostly ASCII. The string is something like:
var a = "var x = '\x68\x6F\x6C\x61\x61\x61\x61\x20\x6D\x75\x6E\x64\x69\x6C\x6C\x6F\x6F\x6F\x6F\x6F'";
The contents of the variable a
try to write it to a file, but at the moment of creating the file all the hexadecimal content is converted to ASCII. : (
I already tried to modify the string by replacing the \
with double \
but it does not work because the variable was already interpreted and it is not hexadecimal.
This is how I generate the file:
fs.writeFile('paht/file.js', a, 'utf8', function(e, r){
console.log('litoooo');
});
I already tried changing the encoding to hex
but it does not work either.
At the end of the file output is always:
var x = 'holaaaa mundillooooo'