把 ANSI 編碼轉化爲 UTF-8

2015-09-28  本文已影响89人  district10

文件不多,用 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 

上一篇 下一篇

猜你喜欢

热点阅读