During code compilation today, the following error occurs unexpectedly:
Illegal character: 5279
The file is UTF-8-encoded and should not be wrong.
So I went to the internet to check the information, found that there are two types of UTF-8 encoding:
UTF-8-BOM coding and UTF-8 without BOM coding
Two types of encoding may be suspected.
Due to the error message that the first character of the file is located, it is suspected that the file may contain a BOM mark.
The specific reasons are as follows:
Some editors add the utf8 mark to the utf8 file (editplus calls it a signature). It inserts three invisible characters (0xEF 0xBB 0xBF, or BOM) at the beginning of the file ), it represents the Unicode mark (BOM ). To solve this problem, use editplus to open the File and select Permanet Settings from the Doucument menu. There are three categories: General, File, and Tools. click File, there is a UTF-8 signature on the right: Select always remove signature. click OK. The menu structure of operations under Editplus is as follows: document-> Parameter Settings-> File-> UTF-8 signature-> always remove signature-> OK, this sets the UTF-8 format does not need to add a mark in front of the file, and finally save the file as UTF-8 format.
Solution
Open Notapad ++, import the file, and execute "format (M)-> convert to UTF-8 without BOM encoding format"
Save and exit.