I am using Ubuntu14.04 to connect to a remote host.

Which its version is:

Linux version 2.6.32-431.11.5.el6.yyyzzz.x86_64 (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Thu Jul 3 09:42:34 CST 2014

My upload file on that machine won't display Chinese characters correctly. And I open a file, type randomly Chinese Character with Ubuntu ibus input method. And it shows:


I searched online and tried the following 2 methods:

1: examine the locale

It shows:


Seems no problem.

2: install Chinese Language support package

I did:

yum install "@Chinese Support"

It installed 178M files on that machine.

After that, I open another file, and try typing some Chinese with ibus. But the problem remains, how to solve it?

update1 I did some more research after. I find that some characters can be typed out correctly(via Pinyin input method, ibus). like:

起 度 顿 客

They are all corresponding to their Pinyin. But there is a automate-generated space after each character( not typed by me).

If I try to type 启,杜,盾,刻 (they have the same Pinyin as the above 4 Chinese characters). I got:

�~P�~]~\ ~[� ~H�

For my experience, if the code converting is totally messed up. When I type a Pinyin, I shall get some wired characters which look like Chinese but actually were not, and they will never correspond to that Pinyin I typed.

This time, the things are little bit different.I can type some characters correctly(with an system-generated space), and others are indecipherable.

3 Answers 3


Basically, this may be a problem of mismatch between your locale, which is set to UTF-8, and the encoding of your Chineses character file, which may be encoded in gbk, gb2312, gb18030, or Big-5.

All those encoding listed above are incompatible with UTF-8.

Now, let's assume gbk is the encoding of your file. So when you try to show the contents of the file, a gbk encoded file is interpreted as a UTF-8 file, which causes the gibberish.

Here comes the solution.

  • Use luit. (Preferred)

    $ whatis luit
    luit (1)             - Locale and ISO 2022 support for Unicode terminals

    luit -encoding gbk cat a_chinese_file.txt

Since most (if not every) encoding in use is compatible with ASCII, and if you only need characters in ASCII and another encoding, you can use the following two methods.

  • Change the encoding of your terminal

    You may considered it since this method does not require additional package to be installed.

  • Change Your locale

    But I think this requires you to install the corresponding locale.

Some details about the Chinese encoding mentioned above.

  • gbk, gb2312, gb18030 are encodings for Simplified Chinese.

    If you are not sure which certain encoding your file is using, assume it gb18030.

    Number of characters contained in each encoding follows this: gb18030 > gbk > gb2312. And the superior encoding is a superset of what follows.

  • Big-5 is the encoding for Traditional Chinese.

What's more, encoding for Simplified Chinese is sometimes refered as CP936 (Code Page 936, I think this name comes from Windows).

  • About the terminal issue, I can show the Chinese characters correctly on the terminal as if the file was in my local computer, but when scp it to the remote machine, the characters become uncognizable.
    – ZengJuchen
    Commented Aug 9, 2014 at 6:39
  • By the way, when excute the luit command, I got "Warning: couldn't set locale. Segmentation fault "
    – ZengJuchen
    Commented Aug 9, 2014 at 6:40
  • @Zen There are too many problems to deal with files not encoded in UTF-8. And my suggestion is to convert your Chinese character file to be encoded in UTF-8 if you have control over that. Then everything should be fine.
    – pallxk
    Commented Aug 9, 2014 at 8:23
  • you mean luit can convert it?
    – ZengJuchen
    Commented Aug 9, 2014 at 8:31
  • luit cannot. Use some other tools. I'm not sure which certain tool to use on linux. On Windows, you may use Notepad++.
    – pallxk
    Commented Aug 9, 2014 at 8:37

I just added this line in ~/.bash_profile:

export LC_ALL=en_US.UTF-8

I think you need to change two files as

1) In /etc/default/locale

LANG=" en_US.UTF-8"
LANGUAGE=" en_US:en.UTF-8"

2) In ~/.pam_environment


3) reboot

You must log in to answer this question.

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