LKBEN11127: How to convert Windows text files.


This article has not been checked!

LKB | Created: 02/04/2020 | Version: 1 | Language: EN | Rating: 0 | Outdated: False | Marked for deletion: False

Author: Wim Peeters - Keskon GmbH & Co. KG

Latest update: 05/10/2020 | Comment:


Symptom

You need to convert text files for linux.

Cause

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

Solution

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
              de_DE.UTF-8

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").

About the Author

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 in different European countries and different European languages. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform where he is one of the most important contributors and the main developer.

Disclaimer:

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!