The problem I'm trying to resolve here is that, in the terminal of an ssh session to an OS X machine, the output of the ls command cannot display utf8 encoded Chinese characters in file names correctly (showing something like ???). The ssh client I'm using is securecrt and putty on Windows (both are configured to use utf8 encoding). Both of them have this problem. On the other hand, utf8 characters in file contents can be displayed correctly (as via vim and cat), and the auto complete feature of bash can also display utf8 characters in file names correctly (both in the candidates list when there are multiple candidates, and in the file name that gets auto completed when there is only one candidate.)

So the question is, how to make ls correctly display utf8 encoded file names in the terminal of an ssh session to an OS X machine?


This problem is usually caused due to environmental variables, so please check it first. type env you can get the result. In my case set LANG(export LANG=en_US.UTF-8) just work.


For Putty: On the OSX target machine, lookup the LC_CTYPE environment variable (echo $LC_CTYPE). It should be UTF-8 or something like en_EN.UTF-8. (If it's only something like "en_EN" then it's set to ISO. In this case change it to en_EN.UTF-8 by adding export LC_CTYPE=en_EN.UTF-8 to your $HOME/.bash_profile). On your windows machine in Putty go to the configuriation -> window/translatation and there select the same character set as the env var on your OSX machine. If both the env var on the server and the putty settings are the same, it should be working.

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.