編碼的問題,查了一下解決的方式如下,
因為系統預設是 UTF-8 的環境,如果要連到 Big-5 的 BBS 站台,
1.就要透過 luit 來指定編碼:
luit -encoding big5 telnet ptt.cc
2.另外一個解決方法ssh bbsu@ptt.cc??
3.還有一個解決方法,如果是桌面linux,直接調終端機編碼就行
2019年10月27日 星期日
如何在 Debian 10 將 VIM 將ANSI檔案轉存為UTF-8編碼
工作上常常會把 Excel 轉存為 CSV 後,再利用有正規表示式 (regular expression) 置換能力的 VIM 來轉換為 SQL 語句。
但是 Excel 轉存的 CSV 檔是 ANSI 編碼,如果出現 UTF-8 的特殊怪字時,會無法存檔。這時候就要下個轉編碼格式儲存的指令:
這個指令是 Google 查到 "How can I change a file's encoding with vim?" 這篇文章看到的。
使用vim做到這一點是完全可能的,為什麼不簡單使用iconv?我的意思是-加載文本編輯器只是為了進行編碼轉換似乎就像對釘子太小使用了太大的錘子。
只是:
It could be useful to change the encoding just on the command line before the file is read:
但是 Excel 轉存的 CSV 檔是 ANSI 編碼,如果出現 UTF-8 的特殊怪字時,會無法存檔。這時候就要下個轉編碼格式儲存的指令:
:write ++enc=utf-8讓寫檔時是以 UTF-8 格式儲存之。
這個指令是 Google 查到 "How can I change a file's encoding with vim?" 這篇文章看到的。
:write ++ enc = utf-8 russian.txt因此,您應該能夠在write命令中更改編碼。
使用vim做到這一點是完全可能的,為什麼不簡單使用iconv?我的意思是-加載文本編輯器只是為了進行編碼轉換似乎就像對釘子太小使用了太大的錘子。
只是:
iconv -f utf-16 -t utf-8 file.xml > file.utf8.xml
這樣就完成了。It could be useful to change the encoding just on the command line before the file is read:
rem On MicroSoft Windows vim --cmd "set encoding=utf-8" file.ext # In *nix shell vim --cmd 'set encoding=utf-8' file.ext
訂閱:
文章 (Atom)