How can I enable UTF-8 support in the Linux console?
Check that you have the locales
package installed
dpkg -l locales
If not, install it
apt-get install locales
As root, type
dpkg-reconfigure locales
you can navigate that list with the up/down arrow keys, for example choose en_US-UTF-8
edit your .bashrc
by adding the following lines:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
Run the locale
command ,the output should be similar to this::
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Sure (it's limited on the number of glyphs, but it seems your locale is using UTF-8 encoding).
I use this for testing:
#!/bin/sh
# send character-string to enable UTF-8 mode
if test ".$1" = ".off" ; then
printf '\033%%@'
else
printf '\033%%G'
fi
and (calling it "utf8"), "utf8 on" turns the encoding on.
Using the example given with pstree
, here is an example after running the script (before, the same sort of output as in the question):
As noted in a comment, there's a script unicode_start
which does more, but all that is needed to address the question posed is the small script used as an example.
Addressing a different comment: At least on my system (and in the screenshot shown in the question), all of the characters used by pstree
are supplied in the 512-glyph font used by default for Unicode support in the Linux console.
Further reading:
- console_codes - Linux console escape and control sequences
- Into the Mist: How Linux Console Fonts Work
Set CHARMAP="UTF-8"
in /etc/default/console-setup
.
Run systemctl daemon-reload && systemctl restart console-setup.service
afterwards.