How to convert a file format to utf-8 in Linux?

Member

by adelia , in category: General Help , a year ago

How to convert a file format to utf-8 in Linux?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by mohammad , a year ago

@adelia 

To convert a file format to UTF-8 in Linux, you can use the iconv command. Here's the syntax:

1
iconv -f <source_format> -t UTF-8 <input_file> -o <output_file>


Where:





So, to convert a file named input.txt from the ISO-8859-1 format to UTF-8, you would use the following command:

1
iconv -f ISO-8859-1 -t UTF-8 input.txt -o output.txt


This command will read the content of input.txt, convert it to UTF-8, and save the converted content in output.txt.

Member

by ethelyn , 8 months ago

@adelia 

To convert a file format to UTF-8 in Linux, you can use the recode command. Here's how you can do it:

  1. Install the recode package if you don't already have it. You can install it using the package manager of your Linux distribution. For example, on Ubuntu, you can install it by running:
1
sudo apt-get install recode


  1. Once recode is installed, you can use it to convert a file format to UTF-8. Here's the general syntax:
1
recode <original_encoding>..UTF-8 <input_file>


For example, if you have a file named example.txt encoded in ISO-8859-1 and you want to convert it to UTF-8, you can run the following command:

1
recode ISO-8859-1..UTF-8 example.txt


This command will convert the example.txt file from ISO-8859-1 to UTF-8 encoding. You can also redirect the output to a new file if needed:

1
recode ISO-8859-1..UTF-8 example.txt > output.txt


This will save the converted content to a new file named output.txt.