Weird Characters in Terminal

From TheBeard Science Project Wiki
Revision as of 00:15, 14 January 2020 by Beard (talk | contribs)

Jump to: navigation, search

Sometimes there is a mismatch between the system locale and the terminal's encoding scheme. The example below is using Ubuntu Server 18.04 and PuTTY.

Use the locale command to view the language and encoding scheme environment variables:

neuro@neuromancer:~$ locale
LANG=
LANGUAGE=
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=

You can see that the variables LANG, LANGUAGE, and LC_ALL are not set. You can set them temporarily like this (assuming you want US English and UTF-8):

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Put these export commands at the end of your ~/.bashrc file to set these variables on login for your user account only.

To make these permanent system-wide, edit the file /etc/default/locale and enter these lines:

LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8

Log out and log in again for these defaults to take effect.

Now, make sure the character encoding in your terminal emulator is set to UTF-8. In PuTTY, right-click the window frame and click "Change Settings...".

Under Window > Translation, set the "Remote character set" to "UTF-8". I also set the radio button "Use Unicode line drawing code points".

Then Under "Session", Click "Default Settings" and click "Save".

Now click "Apply" at the bottom of the window.