When a space is not a space
Text that looks identical on screen can be made from different characters. A normal space typed in a code editor is usually an ordinary space character. But text copied from a webpage, document, or chat may contain a nonbreaking space—a character designed to keep words together—or a zero-width character that takes up no visible room.
Those characters matter because a compiler does not judge code by appearance. It reads a sequence of character values, then applies the programming language’s rules to that sequence. A nonbreaking space may look like a regular gap but fail to count as permitted whitespace between tokens. A hidden character inside a name or punctuation can likewise make the sequence unlike the one the programmer intended. The result may be a syntax error, or code that behaves differently from what its appearance suggests.
Why the error seems to point elsewhere
Compilers and editors often report the line and position where parsing went wrong, but the suspicious character may be hard to see—or the parser may only become confused at a later character. That can make a perfectly ordinary-looking line seem inexplicably invalid. The problem is especially common when code is copied from formatted text, where typography and layout can introduce characters that are useful for reading but not valid in source code.
A practical fix is to inspect the reported line with an editor setting that displays whitespace or unusual characters, then replace the suspect gap or symbol by typing it again. If the code is short, retyping the line can be faster than hunting for a character that has no visible shape. The key lesson: source code is a precise character sequence, not just the picture your screen draws.






