Operation and maintenance stepped pit referred to - read text <U + FEFF>

 

1. Place the file on linux use the less command to see: less xxx.txt

2. Remove the extra characters

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. Search for bom file contains the command:

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

Nkf can also be used to check the file encoding: nkf --guess * / * | grep BOM

-j: converted to JIS encoding (ISO-2022-JP), default
-e: converted to EUC code
-s: Shift-JIS coding is converted to
-w: converted to UTF-8 encoding (without BOM)
-Lu: unix line format is converted to (LF)
-Lw: convert windows-line format (CRLF)
-Lm: macintosh line format is converted to (CR)
-g (- guess): automatically determine and display the encoded
--version: show the version
--help: Display help

linux is converted into window: nkf -sxLw nkf -swLw

window is converted into linux: nkf -wxLu

$ nkf -w myfile.txt >> test
this command means is to convert the contents of the file into a text file myfile.txt utf8 encoding and then output to a file in test

 

 




Guess you like

Origin www.cnblogs.com/RocCnBlog/p/12603555.html