Create a simple JS:
console.log('English');
console.log('中文');
And then in Powershell, run it with node.js:
PS D:\temp\1> node .\a.js
English
中文
Now, print it with echo, or redirect it to a file, or use tee:
PS D:\temp\1> node .\a.js | echo
English
涓枃
PS D:\temp\1> node .\a.js > log.txt
Both the print (above) and the log.txt file are garbled. I tried it on a Chinese Windows and English Windows, same result.
How do I fix it?
By the way, Python works fine:
print('Print some English')
print('Print some Chinese: 中文中文中文')
PS D:\temp\1> python .\a.py
Print some English
Print some Chinese: 中文中文中文
PS D:\temp\1> python .\a.py | echo
Print some English
Print some Chinese: 中文中文中文