Unicode in code oddity

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
6,282
image.png

The above C++ code looks wierd, but it's valid?, and compiles fine because of a unicode oddity, zero width space.

The above code works because it is written like this.
Code:
#include <iostream>

int main()
{
    int abc = 1;
    int ab\u200Bc = 2;
    int a\u200Bbc = 3;

    std::cout << abc << std::endl; // prints 1
    std::cout << ab\u200Bc << std::endl; // prints 2
    std::cout << a\u200Bbc << std::endl; // prints 3

    return 0;
}
 
Top