Site Tools


debian:utf8andbash

UTF-8 in Bash

Bash has no problems with UTF-8 support. That is, as long as Bash knows you want UTF-8. To get it set up on a Debian box you need to edit 2 files and execute 1 script.

edit /etc/locale.gen and remove the “hash” in front of the UTF-8 language of your choice (ie. English = en_US UTF-8, German = de_DE UTF-8). Activating multiple Languages is allowed. Once you are done save the changes and execute the following:

ROOT
root@some-system:~# locale-gen Generating locales (this might take a while)… .de_DE.UTF-8… done .en_US.UTF-8… done Generation complete. root@some-system:~#_

This generates the correct locales for your system according to your selections.

The last step is to modify your ~/.bashrc. Once you are happy with the settings you can add the changes to the system skel so all new users have the same support.

export LANG=en_US.UTF-8
export LESSCHARSET=utf-8
export PERL_UTF8_LOCALE=1 PERL_UNICODE=AS

After saving the changes just exit your shell and log back in to have the changes.

Enjoy.

debian/utf8andbash.txt · Last modified: 2020/02/24 11:16 (external edit)