How to enable UTF-8 in Linux? [SOLVED]


Omer Cakmak

Tips and Tricks

What is UTF-8?

UTF-8 (Unicode Transformation Format) is an 8-bit Unicode conversion format. It is used to encode Unicode characters in groups of 8-bit variable byte numbers. Character encoding is a way of telling a computer how to interpret raw zeros and ones into real characters. When we write text to a file, the words and sentences we create are made up of different characters, and the characters are arranged in a character set. Or the codes written in a programming language are converted into this format by the system and presented to the user.

For example, in the Mousepad application, UTF-8 is defined as the default encoding:

How to enable UTF-8 in Linux? [SOLVED]

 

If you are working on Linux operating system, you should use these converters. If you have received a warning/error regarding UTF-8, read this post. In this article, we will explain the steps to enable UTF-8 on Linux operating systems.

Let's enable UTF-8 for systems based on major distributions that are used by most users on Linux.

 

How to enable UTF-8 Redhat Based OS

The following steps can be applied in linux distributions based on Redhat operating system such as Centos, Rocky Linux, AlmaLinux, Fedora, etc.

 

Step-1: Show current UTF-8 settings

First view the settings current in the system:

[foc@rocky9 ~]$ locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
...

or

[foc@rocky9 ~]$ localectl 
   System Locale: LANG=en_GB.UTF-8
       VC Keymap: us
      X11 Layout: us

The language you used and the UTF format are also displayed.

 

Step-2: Show the list of available locales

Use the following command to list available languages and UTF formats:

[foc@rocky9 ~]$ localectl list-locales
...
en_SC.UTF-8
en_SG.UTF-8
en_US.UTF-8
...

After this command, you will see a long list.

 

Step-3: Change UTF-8 setting

To change the UTF settings, you can do it by giving the set-locale and LANG parameters to the localectl command. For example:

[foc@rocky9 ~]$ sudo localectl set-locale LANG=en_US.UTF-8

or you can manually edit the /etc/locale.conf file:

[foc@rocky9 ~]$ sudo vi /etc/locale.conf

Change en_GB.UTF-8 to en_US.UTF-8. Then check system locale settings:

[foc@rocky9 ~]$ cat /etc/locale.conf 
LANG=en_GB.UTF-8

 

How to enable UTF-8 Debian Based OS

In this step, let's explain how to make UFT settings in distributions such as Debian based systems, Pardus, Ubuntu, Mint.

 

Step-1: Show current UTF-8 settings

You can view the UTF settings with the locale command:

foc@ubuntu22:~$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
...

 

Step-2: Show the list of available locales

Reconfigure the locales package to show the list of available locales:

foc@ubuntu22:~$ sudo dpkg-reconfigure locales

enable UTF-8

 

Step-3: Change UTF-8 setting

Run the locales package with root user or sudo:

How to enable UTF-8 in Linux? [SOLVED]

 

Select UTF and language from the list. Determine which of the selected settings will be default:

How to enable UTF-8 in Linux? [SOLVED]

 

Press OK:

foc@ubuntu22:~$ sudo dpkg-reconfigure locales
Generating locales (this might take a while)...
  en_GB.UTF-8... done
  en_US.UTF-8... done
  tr_TR.UTF-8... done
Generation complete.

The settings have been applied successfully.

 

References

unix.stackexchange.com - How can I enable UTF-8 support in the Linux console?

 

Views: 193

Omer Cakmak

He is highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware. You can connect with him on LinkedIn or check his projects on GitHub page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

Leave a Comment

GoLinuxCloud Logo


We try to offer easy-to-follow guides and tips on various topics such as Linux, Cloud Computing, Programming Languages, Ethical Hacking and much more.

Programming Languages

JavaScript

Python

Golang

Node.js

Java

Laravel