1.将文件放到linux上使用less命令查看: less xxx.txt

2.去掉多余的字符

1)In your terminal, open the file using vim:
vim file_name
2) Remove all BOM characters:
:set nobomb
3) Save the file:
:wq

3.搜索含有 bom 的文件命令:

grep -r -I -l $'^\xEF\xBB\xBF' ./

也可以用 nkf 检查文件编码 :nkf --guess */* | grep BOM

-j           : 转换为 JIS 编码(ISO-2022-JP),默认
-e           : 转换为 EUC 编码
-s           : 转换为 Shift-JIS 编码
-w           : 转换为 UTF-8 编码(无BOM)
-Lu          : 转换为 unix 换行格式(LF)
-Lw          : 转换为 windows 换行格式(CRLF)
-Lm          : 转换为 macintosh 换行格式(CR)
-g(--guess)  : 自动判断编码并显示
--version    : 显示版本
--help       : 显示帮助

linux中转换成window     :   nkf -sxLw    nkf -swLw

window转换成linux         :   nkf -wxLu

$nkf -w myfile.txt >> test
这个命令的意思就是把文件myfile.txt文件文本的内容转换成utf8的编码然后输出到文件test中

 

 




相关文章:

  • 2022-12-23
  • 2021-10-23
  • 2021-06-09
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2021-04-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2021-08-14
  • 2021-12-05
  • 2022-12-23
  • 2021-05-17
相关资源
相似解决方案