Bootstrap FreeKB - Linux Commands - iconv (character encoding standard)
Linux Commands - iconv (character encoding standard)

Updated:   |  Linux Commands articles

In this example, a .txt file was created in Windows Notepad, and the file contains the special character â.

 

When attempting to view this file using a Linux text editor, the â character may not be displayed. This problem occurs because the text editor or the Linux system may not use a character encoding standard that supports the â character.

 


LC_ALL

One solution to this problem is to update the LC_ALL variable in the /usr/bin/locale file to use a character encoding standard that supports the â character, such as UTF8.

LC_ALL=en_US.utf8

 

The Linux text editor now properly displays the â character.

 

However, setting the LC_ALL variable to use UTF8 may not be an ideal solution, because this would update the entire operating system to use UTF8. The iconv command can be used to update the file to use UTF8.

 


iconv

The iconv command with the -f or --from-code and -t or --to-code options can be used to convert a file from a certain character encoding standard to another character encoding standard. For example, to convert example.txt from ISO-8859-15 to UTF8, and to make a new file named newfile.txt.

[root@server1 ~]# iconv -f iso-8859-15 -t UTF-8 /home/user1/example.txt > /home/user1/newfile.txt

 

newfile.txt will properly display the â character.

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 461127 in the box below so that we can be sure you are a human.