Why doesn't my terminal output unicode characters properly?

牧云@^-^@ 提交于 2019-12-17 15:28:03

问题


For example, my terminal does this:

$ echo -e "\xE2\x98\xA0"
���

I expect it to do this:

$ echo -e "\xE2\x98\xA0"
☠

Why? How do I make my terminal output the proper unicode symbols?

I'm using Gnome 3's Terminal on Arch Linux.

The output of locale shows:

LANG=C
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=

回答1:


I figured it out. I had to make sure I set LANGUAGE="en_US.UTF-8" in /etc/rc.conf and LANG="en_US.UTF-8" in /etc/locale.conf, then logged out and logged back in and it worked. My terminal displays unicode properly now.




回答2:


In case you cannot change /etc/* files, you can manually set the gnome-terminal menu Terminal|Set Character Encoding to Unicode(Utf-8)




回答3:


I updated my locale with the following command:

sudo update-locale LANG=en_US.UTF-8 LANGUAGE=en.UTF-8

then rebooted:

sudo reboot


来源:https://stackoverflow.com/questions/12649896/why-doesnt-my-terminal-output-unicode-characters-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!