ISO8859-15でエンコードされたアラビア語ファイルがあります。どうすればUTF8に変換できますか?
使用iconv
しましたが、うまくいきません。
iconv -f ISO-8859-15 -t UTF-8 Myfile.txt
ファイルを添付したかったのですが、方法がわかりません。
ISO8859-15でエンコードされたアラビア語ファイルがあります。どうすればUTF8に変換できますか?
使用iconv
しましたが、うまくいきません。
iconv -f ISO-8859-15 -t UTF-8 Myfile.txt
ファイルを添付したかったのですが、方法がわかりません。
ファイルがISO-8859-15でエンコードされていない可能性がありますか?fileコマンドで確認できるはずです。
ファイルYourFile.txt
また、元のファイルのエンコーディングを提供せずにiconvを使用できます。
iconv -t UTF-8 YourFile.txt
私はこれが私のために働くことを発見しました:
iconv -f ISO-8859-14 Agreement.txt -t UTF-8 -o agreement.txt
私たちはこの問題を抱えており、解決する必要があります
to-utf8.shというスクリプトファイルを作成します
#!/bin/bash
TO="UTF-8"; FILE=$1
FROM=$(file -i $FILE | cut -d'=' -f2)
if [[ $FROM = "binary" ]]; then
echo "Skipping binary $FILE..."
exit 0
fi
iconv -f $FROM -t $TO -o $FILE.tmp $FILE; ERROR=$?
if [[ $ERROR -eq 0 ]]; then
echo "Converting $FILE..."
mv -f $FILE.tmp $FILE
else
echo "Error on $FILE"
fi
実行可能ビットを設定します
chmod +x to-utf8.sh
変換を行う
./to-utf8.sh MyFile.txt
フォルダ内のすべてのファイルを変換する場合は、
find /your/folder/here | xargs -n 1 ./to-utf8.sh
お役に立てば幸いです。
私の場合、file
コマンドは間違ったエンコーディングを指示しているので、可能なすべてのエンコーディングで変換してみて、正しいエンコーディングを見つけました。
このスクリプトを実行し、結果ファイルを確認します。
for i in `iconv -l`
do
echo $i
iconv -f $i -t UTF-8 yourfile | grep "hint to tell converted success or not"
done &>/tmp/converted
ISO-8859-9エンコーディングを使用できます。
iconv -f ISO-8859-9 Agreement.txt -t UTF-8 -o agreement.txt
同じ問題が発生しましたが、このページで答えを見つけました !それは私のために働きます、あなたはそれを試すことができます。
iconv -f cp936 -t utf-8
Iconvは、変換されたテキストをstdoutに書き込むだけです。パラメータとして使用する-o OUTPUTFILE.txt
か、stdoutをファイルに書き込む必要があります。(iconv -f x -t z filename.txt > OUTPUTFILE.txt
または iconv -f x -t z < filename.txt > OUTPUTFILE.txt
一部のiconvバージョンでは)
Synopsis
iconv -f encoding -t encoding inputfile
Description
The 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 encoding
Convert characters from encoding
--to-code, -t encoding
Convert characters to encoding
--list
List known coded character sets
--output, -o file
Specify output file (instead of stdout)
--verbose
Print progress information.