In Windows 10's
cmd.exe, if I do
tree C:. ├───a │ ├───b │ └───etc...
it clearly display the Unicode bars and dashes correctly on the console.
But if I redirect this output to a file
tree > tree.txt
the contents of the file are:
C:. ³ÄÄÄa ³ ÃÄÄÄb ³ ÀÄÄÄetc...
It fails to properly write the Unicode characters.
It can't even read back what it wrote:
tree > tree.txt type tree.txt C:. ����a � ����b � ����etc...
(it may appear as "�" here (question marks in a tilted square) but in the console they appear as empty boxes)
I've already tried these suggestions without luck:
CMD /U /c tree > tree.txt
I was using this command incorrectly, now fixed, but I still get the same result as just
tree - it displays fine in the console, but file output is still those weird characters.
It's strange that the text displays on the console just fine, but writing to file messes up the encoding. What could be the issue here?