As mentioned by Daneau in the accepted answer, the problem is by a character that is not visible in the IDE.
Here are several solutions to find the invisible character with Notepad++.
Solutions 1: Show Symbol
- Copy the code to Notepad++,
- Select View -> Show Symbol -> Show All Characters
This can show invisible control characters.
Solutions 2: Convert to ANSI
- Copy the code to Notepad++,
- Select Encoding- > Convert to ANSI
This will convert the invisible character to ?
if it is a none ANSI character.
Solutions 3: Remove none ASCII characters
- Copy the code to Notepad++,
- Open the Find window (Ctrl+F)
- Select the Replace tab
- in "Find what" write:
[^\x00-\x7F]
- Leave "Replace with" empty
- In "Search Mode" select "Regular expression"
- Find and remove the none ASCII characters
This will remove none ASCII characters.
Note: This can remove valid non ASCII characters (in strings and comments) so try to skip those if you have any.
Tip: Use HEX-Editor plugin
Use Notepad++ HEX-Editor plugin to see the binary code of text. Any character out of the range of 0x00 - 0x7F (0 - 127) is a non ASCII character and a suspect of being the problem.