The Hidden Danger of Invisible Zero-Width Characters in Source Code
Invisible characters—such as Zero-Width Space (U+200B), Zero-Width Non-Joiner (U+200C), and Byte Order Marks (U+FEFF)—are imperceptible in standard code editors because they render with zero glyph width. However, when copied into source code, configuration files, or database queries, compilers and parsers treat them as distinct byte sequences, triggering mysterious "Unexpected token", "Invalid character", or "SyntaxError" exceptions that can take hours to manually diagnose.
// Example: Mysterious Syntax Error caused by ZWSP
// ❌ Looks identical in plain text editors, but fails to parse:
const apiKey = "secret_123"; // Contains U+200B between 'api' and 'Key'!
// Runtime: ReferenceError: apiKey is not defined
// ✅ Cleaned standard ASCII identifier:
const apiKey = "secret_123";