6
▶ 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

7

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.

3
  • 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
  • -N fix Chinese issue.
    – Sun Junwen
    Aug 2, 2022 at 2:17
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

You must log in to answer this question.

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