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.
Best Answer
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
I found this to work for me:
iconv -f ISO-8859-14 Agreement.txt -t UTF-8 -o agreement.txt
I have ubuntu 14 and the other answers where no working for me
iconv -f ISO-8859-1 -t UTF-8 in.tex -o out.tex
I found this command here
We have this problem and to solve
Create a script file called to-utf8.sh
#!/bin/bashTO="UTF-8"; FILE=$1FROM=$(file -i $FILE | cut -d'=' -f2)if [[ $FROM = "binary" ]]; thenecho "Skipping binary $FILE..."exit 0fiiconv -f $FROM -t $TO -o $FILE.tmp $FILE; ERROR=$?if [[ $ERROR -eq 0 ]]; thenecho "Converting $FILE..."mv -f $FILE.tmp $FILEelseecho "Error on $FILE"fi
Set the executable bit
chmod +x to-utf8.sh
Do a conversion
./to-utf8.sh MyFile.txt
If you want to convert all files under a folder, do
find /your/folder/here | xargs -n 1 ./to-utf8.sh
Hope it's help.
I got the same problem, but i find the answer in this page! it works for me, you can try it.
iconv -f cp936 -t utf-8
in my case, the file
command tells a wrong encoding, so i tried converting with all the possible encodings, and found out the right one.
execute this script and check the result file.
for i in `iconv -l`doecho $iiconv -f $i -t UTF-8 yourfile | grep "hint to tell converted success or not"done &>/tmp/converted
You can use ISO-8859-9 encoding:
iconv -f ISO-8859-9 Agreement.txt -t UTF-8 -o agreement.txt
Iconv just writes the converted text to stdout. You have to use -o OUTPUTFILE.txt
as an parameter or write stdout to a file. (iconv -f x -t z filename.txt > OUTPUTFILE.txt
or iconv -f x -t z < filename.txt > OUTPUTFILE.txt
in some iconv versions)
Synopsisiconv -f encoding -t encoding inputfileDescriptionThe iconv program converts the encoding of characters in inputfile from one coded character set to another. **The result is written to standard output unless otherwise specified by the --output option.**--from-code, -f encodingConvert characters from encoding--to-code, -t encodingConvert characters to encoding--listList known coded character sets--output, -o fileSpecify output file (instead of stdout)--verbosePrint progress information.