Why doesn't my terminal output unicode charact

2019-01-13 10:10发布

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=

3条回答
看我几分像从前
2楼-- · 2019-01-13 10:35

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.

查看更多
混吃等死
3楼-- · 2019-01-13 10:36

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

查看更多
Emotional °昔
4楼-- · 2019-01-13 10:49

I updated my locale with the following command:

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

then rebooted:

sudo reboot
查看更多
登录 后发表回答