Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert ISO8859-15 to UTF8?

Tags:

linux

text

bash

I have an Arabic file encoded in ISO8859-15. How can I convert it into UTF8?
I used iconv but it doesn't work for me.

iconv -f ISO-8859-15 -t UTF-8 Myfile.txt 

I wanted to attach the file, but I don't know how.

like image 425
Hakim Avatar asked Jul 03 '12 18:07

Hakim


People also ask

How do I convert to UTF-8?

Click Tools, then select Web options. Go to the Encoding tab. In the dropdown for Save this document as: choose Unicode (UTF-8). Click Ok.

How do I change the encoding of a file in Linux?

In Linux, the iconv command line tool is used to convert text from one form of encoding to another. Where -f or --from-code means input encoding and -t or --to-encoding specifies output encoding.

What is the difference between UTF-8 and ISO 8859 1?

UTF-8 is a multibyte encoding that can represent any Unicode character. ISO 8859-1 is a single-byte encoding that can represent the first 256 Unicode characters. Both encode ASCII exactly the same way.

How do I convert UTF-8 to ISO 8859 1?

Going backwards from UTF-8 to ISO-8859-1 will cause "replacement characters" (�) to appear in your text when unsupported characters are found. byte[] utf8 = ... byte[] latin1 = new String(utf8, "UTF-8"). getBytes("ISO-8859-1"); You can exercise more control by using the lower-level Charset APIs.


2 Answers

Could it be that your file is not ISO-8859-15 encoded? You should be able to check with the file command:

file YourFile.txt

Also, you can use iconv without providing the encoding of the original file:

iconv -t UTF-8 YourFile.txt
like image 151
HighKing Avatar answered Oct 03 '22 13:10

HighKing


I found this to work for me:

iconv -f ISO-8859-14 Agreement.txt -t UTF-8 -o agreement.txt 
like image 45
Colin Keenan Avatar answered Oct 03 '22 13:10

Colin Keenan