Some editors (for example, notepad) add BOM (byte bytes) signatures while saving UTF-8 text. You should check 0xEF, 0xBB, 0xBF bytes before reading a line from such a file and skip them if they exist.
Another way is not to use notepad to edit UTF-8 texts, get another program, such as Notepad ++, Kate or something else, with which you can control the addition of the specification.
source share