讓vim同時能讀寫utf8和big5的檔案

edit ~/.vimrc

set enc=utf-8
set fileencodings=utf-8,cp950,ucs-bom,default,latin1
set termencoding=cp950

重點是termencoding,vim會把utf8格式的檔案讀出來轉成termencoding (for terminal),也就是big5,於是putty / screen可以直接用big5(cp950)接收,不用為了讀寫utf8對putty / screen做一堆設定

可參考 fileencodings、 fileencoding、 encoding 和 termencoding

from 讓vim同時能讀寫utf8和big5的檔案

另外,可以在unix下轉編碼

iconv -f big5 -t utf-8 liu.cin

把 liu.cin 這個檔案由 big5 碼轉成 utf-8 編碼。
iconv 指令,-f 是 from 原始編碼,-t 是 to 目的編碼。

from linux中unicode & utf-8 & big5互轉??

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *