Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I do a tree > somefile.txt the file indeed contains the output of the tree command, but the lines drawn in the console are displayed as accented letters ÃÄÄÄ.

Which encoding or mode do I have to use to display such an output file correctly and which editor can do it?

share|improve this question
up vote 3 down vote accepted

treesupports the /a switch which uses regular ASCII:

D:\>tree /a
Folder PATH listing for volume Win7
Volume serial number is BA60-7CCB
D:.
+---3rd
|   +---Android
|   |   +---android-ndk-r5
|   |   |   +---build
|   |   |   |   +---awk
|   |   |   |   +---core
|   |   |   |   +---gmsl
|   |   |   |   \---tools
share|improve this answer

It probably uses the line-drawing characters in code page 850.

Notepad doesn't support that encoding, it's default is "ANSI", by which Microsoft mean Windows-Latin1 or Code-Page-1252 if I remember correctly.

Notepad++ or gVim etc should be able to display the characters correctly.

share|improve this answer
    
gVim defaults to latin1, but the command :set enc=cp850 will fix it. – Kevin Panko Sep 17 '14 at 12:42

In Notepad++, I was able to read them when selecting the "Encoding" under "Character Sets" > "Western European" > "OEM-US".

After that I could select "Encoding" > "Convert to UTF-8", so I could transfer them in a format that hopefully everyone else would be able to read.

For reference, my system is Windows 7 Professional SP1 64-bit(x64), with my current system locale set to "English (United States)".

Also, I believe this question has more information and if higher rated: Saving 'tree /f /a" results to a textfile with unicode support

I also run my Command Prompt with the "/U" option (through ConEmu if that matters), and an answer on that page had stated: Either that does not function as expected, or the tree command does not respect it for some reason. I have now found this excerpt from the following source, that may explain why the tree command does not write Unicode-encoded text to a file:

Output UNICODE characters (UCS-2 le)
These options will affect piping or redirecting to a file.
Most common text files are ANSI, use these switches
when you need to convert the character set.

In my environment however, I have used output redirector character > to write to a file, so the command is not doing this itself, and the output was still not encoded in a Unicode format.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .