1
我有utf-8與俄羅斯字符我嘗試複製到新文件 但結果是亂碼字符。 源文件可以打開並在vim中看到很好。 這是我的腳本的一部分,Linux csh,從utf-8文件複製文本到其他文件結果亂碼
# this is how i found in the internet to convert file to utf-8
set new_file_full_path = "/home/foo/env/output/test.csv"
set f = "/home/foo/env/source/source_test.txt"
if(! -e $new_file_full_path) then
touch $new_file_full_path
iconv -f latin1 -t utf8 $new_file_full_path
endif
set new_line_buffer = ""
foreach line("`cat $source_dir/$f`")
#echo $line
if($i > 14) then
echo "about to append to file"
echo $new_file_full_path
echo $line >> $new_file_full_path
echo "done append to file"
endif
@ i = $i + 1
end
我認爲問題的一部分是,當我這樣做:
目標文件
file -i /home/foo/env/output/test.csv
/home/foo/env/output/test.csv: text/plain; charset=unknown-8bit terminators
和源文件
file -i /home/foo/env/source/source_test.txt
text/plain; charset=utf-8
因爲您看到目標文件並非utf-8文件,即使我嘗試將其轉換爲
它不工作我曾經做過什麼 – user63898
對不起,我沒有意識到:[拉丁1](http://en.wikipedia.org/wiki/ISO/IEC_8859-1)可能不是您想要的編碼文件:它不支持俄文字符。您可能想嘗試[ISO_8859-5](http://en.wikipedia.org/wiki/ISO/IEC_8859-5)。 順便說一句,我不知道你在'endif'之後做什麼... – Coconop