Method

The original Emacs in terminal is OK for Chinese input (although I hardly input any Chinese character in a terminal), while it cannot handle switching to Chinese input method in a UI mode. So I googled and found the solution for that.

ps: my Chinese input method is FCITX with Wubi.

If I start Emacs with LC_CTYPE=zh_CN.UTF-8 emacs, the Chinese input is OK as it should be. I understand this command as to run Emacs in a zh_CN.UTF-8 environment, so I assume that if the whole system’s locale is zh_CN.UTF-8, there won’t be any problem. From Arch Wiki, you can check this by locale command to list your locale settings. Mine is list below:

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE=C
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

You can see my system environment is en_US.UTF-8, in order to enable my fcitx input method, I need to temporal change it to zh_CN.UTF-8. Since there is no difference to input English under either locale environment, so I decide to make zh_CN.UTF-8 mode as Emacs’s default setting. Considering I used to live in a emacsclient mode, so I start up the daemon in awesome‘s auto run applications list:
awful.util.spawn_with_shell("LC_CTYPE=zh_CN.UTF-8 emacs --daemon")

So, job’s done!

I found someone used a different technique to modify the emacs binary file, but I cannot understand that and I don’t want to test it in my working laptop in case it ruins my emacs. :D
Maybe, I will give it a try. remind me here!

1
2
3
4
5
6
sudo mv /usr/bin/emacs /usr/bin/emacs.raw
sudo vi /sur/bin/emacs
---input below content------------------------
#!/bin/bash
export LC_CTYPE=zh_CN.utf8
/usr/bin/emacs.raw "$@"