Linux下文件以及文件名編碼轉換


1.查看文件編碼方式--file 文件名(但不是很准確)

yang@mint-linux ~ $ file baidu.html 
baidu.html: HTML document, UTF-8 Unicode text, with very long lines, with no line terminators
yang@mint-linux ~ $ file sina.html 
sina.html: HTML document, ISO-8859 text, with very long lines, with CRLF, LF line terminators

2.轉換文件編碼--iconv -f 源編碼 -t 目標編碼 源文件名 > 目標文件名

yang@mint-linux ~ $ file sina.html 
sina.html: HTML document, ISO-8859 text, with very long lines, with CRLF, LF line terminators
yang@mint-linux ~ $ iconv -f gbk -t utf8 sina.html > sina_utf8.html
yang@mint-linux ~ $ file sina_utf8.html 
sina_utf8.html: HTML document, UTF-8 Unicode text, with very long lines, with CRLF, LF line terminators

3.轉換文件名編碼--convmv -f 源編碼 -t 目標編碼 文件名 --notext(如果不加--notext則只是顯示結果,不實際轉換)

yang@mint-linux ~ $ touch 中文.txt
yang@mint-linux ~ $ convmv -f utf-8 -t gbk 中文.txt --notest
Your Perl version has fleas #37757 #49830 
mv "./中文.txt"	"./����.txt"
Ready!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM