linux 下修改文件编码格式
2022-07-22 本文已影响0人
Jessie_83bf
1. 为了确定文件的字符编码,我们使用一个名为 “file” 的命令行工具。因为 file 命令是一个标准的 UNIX 程序,所以我们可以在所有现代的 Linux 发行版中找到它。
$ file --mime-encoding filename

2.下一步是查看你的 Linux 系统所支持的文件编码种类。为此,我们使用名为 iconv 的工具及 “-l” 选项(L 的小写)来列出所有当前支持的编码。conv 工具是 GNU libc 库组成部分,因此它在所有 Linux 发行版中都是开箱即用的。
$ iconv -l

3.在我们的 Linux 系统所支持的编码里面选定了目标编码之后,运行下面的命令来完成编码转换:
$ iconv -f old_encoding -t new_encoding filename
例如,把 iso-8859-1 编码转换为 utf-8 编码:
$ iconv -f iso-8859-1-t utf-8input.txt

参考原文 https://www.cnblogs.com/llwang/p/4099695.html