Difference between revisions of "Weird Characters in Terminal"
| Line 44: | Line 44: | ||
Log out and log in again for these defaults to take effect. | Log out and log in again for these defaults to take effect. | ||
| + | |||
| + | If you see that the other variables say "POSIX" or something else, you might need to do these commands: | ||
| + | <source> | ||
| + | sudo locale-gen en_US en_US.UTF-8 | ||
| + | sudo dpkg-reconfigure locales | ||
| + | </source> | ||
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...". | 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...". | ||
Revision as of 00:28, 14 January 2020
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.
You can see some characters display oddly:
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-8Put 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-8Log out and log in again for these defaults to take effect.
If you see that the other variables say "POSIX" or something else, you might need to do these commands:
sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure localesNow, 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.
The character display should now be fixed:
neuro@neuromancer:~/Documents$ tree -L 1
.
├── Books
├── Business
├── Code
├── Datasheets
├── Financial
├── Game Stuff
├── Labels
├── Network
├── Personal Documents
├── Receipts
├── Schematics
├── Technical
├── Web Documents
└── Work
14 directories, 0 files