I have a simple javascript file (let's call it index.js) with the following:
console.log('pérola');
I use VSCode on windows 10 and it uses as terminal the powershell, when I execute the file using:
node index.js
I get the following output:
pérola
If I run the following:
node index.js > output.txt
I get the following on the file:
p├®rola
It seems there is some issue with the encoding of powershell when writing to files, when I open the file on VSCode I can see on the bottom right that the encoding is UTF-16 LE.
I also already tried the following:
node index.js | out-file -encoding utf8 output.txt
The file is saved in UTF8 with BOM but still with wrong encoding since what I see is p├®rola and not pérola
Can someone explain me what is wrong here? Thank you.