1.下载安装 enca 官网:https://dl.cihar.com/enca/
wget https://dl.cihar.com/enca/enca-1.19.tar.xz && \
tar -Jxvf enca-1.19.tar.xz && \
cd enca-1.19 && \
./configure --prefix=/usr/local/enca-1.19 && \
make && make install && \
export PATH=/usr/local/enca-1.19/bin:$PATH
验证安装是否成功及版本:
[root@localhost enca-1.19]$enca --version
enca 1.19
Features: -librecode-interface +iconv-interface +external-converter +language-detection +locale-alias +target-charset-auto +ENCAOPT
Copyright (C) 2000-2005 David Necas (Yeti) (<yeti@physics.muni.cz>),
2005 Zuxy Meng (<zuxy.meng@gmail.com>).
Enca is free software; it can be copied and/or modified under the terms of
version 2 of GNU General Public License, run `enca --license' to see the full
license text. There is NO WARRANTY; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
2.批量转换文件
实例:把当前目录下 及其 子目录中的 python文件转为utf8
find . -type f -name "*.py" -exec enca -L zh_CN -x UTF-8 {} \;