As Stack Exchange doesn't like me posting null bytes, here is an xxd -g1
:
00000000: 6d 00 61 00 69 00 6e 00 28 00 29 00 7b 00 70 00 m.a.i.n.(.).{.p.
00000010: 75 00 74 00 73 00 28 00 22 00 48 00 65 00 6c 00 u.t.s.(.".H.e.l.
00000020: 6c 00 6f 00 2c 00 20 00 57 00 6f 00 72 00 6c 00 l.o.,. .W.o.r.l.
00000030: 64 00 21 00 22 00 29 00 3b 00 7d 00 d.!.".).;.}.
For an infinitely less readable textual version, with 0
representing a raw 0x00
byte:
m0a0i0n0(0)0{0p0u0t0s0(0"0H0e0l0l0o0,0 0W0o0r0l0d0!0"0)0;0}0
Explanation
I'll see your small brain comment abuse and raise you one cosmic brain text encoding abuse. 😏
Unlike GCC and Clang, MSVC supports files encoded in UTF-16.
That is what we abuse. MSVC will """incorrectly""" auto-detect this file as-is as UTF-16LE, causing it to """incorrectly""" read it as this, encoded in UTF-16LE:
main(){puts("Hello, World!");}
If we remove every other character (a.k.a. removing every 00
byte), it treats it as UTF-8 (well, technically, the current SBCS/MBCS codepage), and it is compiled as you would probably expect, as the codepoints are now the same as they were in UTF-16LE:
main(){puts("Hello, World!");}
You may say "but this is UTF-16, it should be mi({us"el,Wrd";
", but I say that U+0000 is a valid UTF-8 codepoint, and it just looks like UTF-16 by """coincidence""".