把 ANSI 編碼轉化爲 UTF-8

文件不多,用 Notepad++ 就可以。但如果……(總之命令行的好處就在這裏,人工畢竟太累。)

# 檢測
$ file -i *
file1: text/plain; charset=utf-8
file2: text/plain; charset=iso-8859-1
file3: text/plain; charset=gbk

# 轉化
$ iconv -f gbk -t utf-8 file3 > file3-utf8.txt # or '-f GBK'

# 列出支持的編碼
iconv -l               # list all supported encodings

或者,用 Vim:

$ vim file3.txt
# convert to utf-8 in place
:w ++enc=utf-8
# write to another file
:w ++enc=utf-8 file3-utf8.txt

vim 相關:

# view in terminal
:set encoding=utf-8

# file in filesystem
:set fileencoding=utf-8

# file format: unix, mac, dos
:set ff=unix 

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容