LKBEN11127: How to convert Windows text files.


You need to convert text files for linux.


You want ti convert Windows text files so that they are displayed correctly under Ubuntu.


Many users want to use their Windows textfiles under Ubuntu but the files aren't correcly displayed. This is because of these text files have no header information unlike Office docs and Linux and Windows are encoding the files in different ways. This is just as well true for HTML files. In a browser the files are displayed correctly because the header information is available but the source files are often saved in ANSI format as plain text files without header information.

Ubuntu offers a simple way of converting the Windows text files in a correct format. Just use the "Recode" command. To install the "recode" packet use the following command:

sudo apt-get install recode

After the packet is installed type "echo $lang" at the command prompt to find out which your current text encrpytion is.
Example: echo $lang

In this example you are using UTF-8 which is widely used. You need this information for the correct recoding of the text files. Now use the recode command to convert the text files:

  recode ms-ansi..UTF-8 test.txt

Hint: If you want to use a filename which contains spaces, set the filename in quotation marks (e.g. "Converted test.txt").


The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!

About the Author

Author: Wim Peeters - Keskon GmbH & Co. KG

Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.

Latest update: 05/10/2020 | Comment: