Why doesn't my terminal output unicode characters properly?

BashShellCommand LineConsoleTerminal

Bash Problem Overview


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=

Bash Solutions


Solution 1 - Bash

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.

Solution 2 - Bash

I updated my locale with the following command:

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

then rebooted:

sudo reboot

Solution 3 - Bash

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

Solution 4 - Bash

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontrusktrView Question on Stackoverflow
Solution 1 - BashtrusktrView Answer on Stackoverflow
Solution 2 - BashBenView Answer on Stackoverflow
Solution 3 - BashNimlarView Answer on Stackoverflow
Solution 4 - BashOldBuildingAndLoanView Answer on Stackoverflow