57

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=
4
  • What operating system are you using? For OS X try: Terminal -> Preferences -> Advanced -> Char. Encoding : UTF-8
    – Omar Wagih
    Commented Sep 29, 2012 at 4:27
  • Besides op sys, also specify what terminal emulator program you use (eg, gnome-terminal, xterm, or others listed in What is the best Linux terminal emulator?), and what character encoding (eg Unicode UTF-8) and font is selected. On my ubuntu 12.04 linux system with gnome-terminal and UTF-8 and Monospace Bold the skull and crossbones appears ok. Commented Sep 29, 2012 at 5:22
  • I'm also using Gnome Terminal... So where do I change those settings? Hmmmm.... I wonder if the face that running locale shows LANG=C is the problem... hmmmmm.
    – trusktr
    Commented Sep 29, 2012 at 6:08
  • @trusktr My locale shows all of items = "en_US.UTF-8" , But I can't stil see unicode characters!
    – Dr.jacky
    Commented Oct 26, 2015 at 12:36

5 Answers 5

18

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
  • 13
    Did not work for me, even though my locale is already correct. Commented Feb 25, 2013 at 6:41
  • 5
    Everyone is moving to systemd these days. If you're using systemd, using rc.conf won't do anything.
    – trusktr
    Commented Feb 27, 2013 at 6:03
  • @trusktr There is no rc.conf ! Just a rc.local !
    – Dr.jacky
    Commented Oct 26, 2015 at 12:34
14

I updated my locale with the following command:

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

then rebooted:

sudo reboot
11

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

2
  • 4
    And if I can change /etc/* , what should I do now?!
    – Dr.jacky
    Commented Oct 26, 2015 at 12:35
  • That worked for me (with GNOME Terminal 2.31.3) while changing the environment variables did not. Commented Sep 18, 2018 at 19:27
1

I was trying to solve this after switching to a new PC. I'm using Windows Terminal with Ubuntu instilled in WSL2 on Win 10.

I tried the suggestions provided here and rebooted; no change.

Solution

The fix for me was installing a patched nerd font and setting the font as the default font for each profile in Windows Terminal settings.

enter image description here

0

with localectl

Possibly through an erroneous line in my .bash_profile, the only thing that helped was:

localectl set-locale en_US.UTF-8

and then rebooting.

The probably problematic line in .bash_profile was:

# ⚠️ Better not do this
export LANG="en_US.utf8"

Notice the difference between ".utf8" and ".UTF-8".

Before running localectl set-locale en_US.UTF-8 the output of localectl status was:

System Locale: LANG=C
    VC Keymap: (unset)
   X11 Layout: (unset)

After running it:

System Locale: LANG=en_US.UTF-8
    VC Keymap: (unset)
   X11 Layout: (unset)

This solved an issue with running fzf in the Linux virtual console and I can now display umlauts and other non-ASCII characters in the virtual console on Arch Linux.

Related questions:

Not the answer you're looking for? Browse other questions tagged or ask your own question.