| 方法 | 指令 | 輸出範例 |
|---|---|---|
| vim | :set fileencoding | fileencoding=utf-8 |
| file | file -i filename | text/plain; charset=utf-8 |
| enca | enca -L zh_CN filename | UTF-8 (需安裝 enca) |
| uchardet | uchardet filename | UTF-8 (需安裝 uchardet) |
# 基本語法
iconv -f FROM_ENCODING -t TO_ENCODING inputfile -o outputfile
# 常用範例
iconv -f UTF-8 -t UTF-16LE input.txt -o output.txt
iconv -f BIG5 -t UTF-8 legacy.txt -o modern.txt
iconv -f GBK -t UTF-8 cn.txt -o cn_utf8.txt
# 批次轉換
for f in *.txt; do
iconv -f GBK -t UTF-8 "$f" -o "${f%.txt}_utf8.txt"
done
iconv --list
| 中文常用名 | iconv 標準名 |
|---|---|
| UTF-8 | UTF-8 |
| UTF-16 Little Endian | UTF-16LE |
| UTF-16 Big Endian | UTF-16BE |
| 繁體中文 Big5 | BIG5 / BIG5-HKSCS |
| 簡體中文 GBK | GBK / GB18030 |
| ISO-8859-1 | ISO-8859-1 |
:set fileencoding=utf-8
:w newfile.txt
file -i 或 uchardet 確認UTF-8,輸出預設不含 BOMLinux Shell 腳本自動輸入密碼:expect 實戰教學(scp/ssh/ftp 通用)
Linux 檔案三大時間屬性詳解:atime、mtime、ctime 差異與修改方法
Linux 文件系統掛載與卸載完整指南:mount / umount / fstab 實戰
深入理解 Linux 用戶與群組機制:/etc/passwd、shadow、group、gshadow 四大核心檔案解析
Java 開發人員必會的 19 個 Linux 常用命令速查
Linux 進程創建核心機制:fork() 系統調用深度解析與代碼實戰