6
0
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:
Try
chcp 1252
orchcp 65001
from the command line. With Lucida Console or other font support.
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?
2
Have a look to this other post related to the same issue
– Ludovic Frérot – 2016-03-23T21:41:50.097Saving 'tree /f /a" results to a textfile with unicode support – phuclv – 2019-11-18T16:13:38.280