4
▶ tree 下载 -L 1
\344\270\213\350\275\275
├── BT
├── ISO
├── Let\ s\ Play\ -\ Sniper\ Elite\ v2\ Nazi\ Zombie\ Army.flv
├── sniper\ elite\ v2\ 02.flv
└── \350\275\257\344\273\266\345\214\205

those 7-bit ASCII output is non identifiable to human. Normally I use ascii2uni -a K to convert into UTF8. but in Fedora 25, the uni2ascii is not in repo. So any other way to make it output UTF8?

2 Answers 2

2

I found another answer on StackOverflow. Making changes to my locale settings didn't help at all, but using the -N option with tree did.

# tree -if ./my-path/
./my-path/Olaf\ Hund\ Vs\ Ursari\ De\ Clejani\ _\ Taraf\ De\ Hai\210douks\ _\ Koçani\ Orkestar\ -\ electric\ gypsyl.mp3


# tree -ifN  ./my-path/
./my-path/Olaf Hund Vs Ursari De Clejani _ Taraf De Haïdouks _ Koçani Orkestar - electric gypsyl.mp3

Note that this also un-escapes spaces.

2
  • It's 2 years post, fc31 is OK now. No need -N or any other command switch.
    – eexpress
    Mar 11, 2020 at 13:39
  • What is fc31? Another command line tool? Mar 12, 2020 at 16:20
1

Set the encoding to UTF-8 (and choose an appropriate locale that has support for Unicode) e.g.:

LC_ALL=en_US.UTF-8 tree -L 1 下载

Presumably you are using a locale that can not interpret those characters (C maybe?).

Example:

% LC_ALL=C tree 下载 
\344\270\213\350\275\275
`-- foo

% LC_ALL=en_US.UTF-8 tree 下载 
下载
└── foo
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.