bash 为什么我的终端不能正确输出 unicode 字符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12649896/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why doesn't my terminal output unicode characters properly?
提问by trusktr
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?
为什么?如何让我的终端输出正确的 unicode 符号?
I'm using Gnome 3's Terminal on Arch Linux.
我在 Arch Linux 上使用 Gnome 3 的终端。
The output of locale
shows:
显示输出locale
:
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=
回答by trusktr
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.
我想到了。我必须确保我LANGUAGE="en_US.UTF-8"
进入/etc/rc.conf
并LANG="en_US.UTF-8"
进入/etc/locale.conf
,然后注销并重新登录并且它工作。我的终端现在可以正确显示 unicode。
回答by Nimlar
In case you cannot change /etc/*
files, you can manually set the gnome-terminal
menu Terminal
|Set Character Encoding
to Unicode(Utf-8)
如果您无法更改/etc/*
文件,您可以手动设置gnome-terminal
菜单Terminal
| Set Character Encoding
到Unicode(Utf-8)
回答by Ben
I updated my locale with the following command:
我使用以下命令更新了我的语言环境:
sudo update-locale LANG=en_US.UTF-8 LANGUAGE=en.UTF-8
then rebooted:
然后重新启动:
sudo reboot