Watching an NDC talk about programming languages I saw this, an implementation of Fizz buzz in APL:

I haven’t ever touched APL, and I know it uses all kinds of weird letters and shapes, but I’m pretty sure it doesn’t use typographical quotes.
Or does it?

Yeah, no, it doesn’t.
Seems to be a case of “copied the code from a web page that performs ‘smart’
quote replacing”. That’s always annoying – not the copying part, but the fact that code on websites gets
demolished by brain-dead Wordpress plugins so often. Replacing the hexadecimal 0x
prefix
with 0×
in the text and even in font ligatures
plays on the same level…
But this got me thinking: How about a compiler that detects code with typographical “enhancements” copied from a website or a Word document and behaves differently? Like a quirks mode for code. Consider:
public class HelloPasteCode { public static void main(String... args) { System.out.println(“Hello world!”); System.out.println(“Hexadecimal 2A is ” + 0×2A); } }
Instead of spewing out ugly error messages:
> java HelloPasteCode.java HelloPasteCode.java:3: error: ')' expected System.out.println(ÔÇ£Hello world!ÔÇ?); ^ HelloPasteCode.java:3: error: not a statement System.out.println(ÔÇ£Hello world!ÔÇ?); ^ HelloPasteCode.java:3: error: ';' expected System.out.println(ÔÇ£Hello world!ÔÇ?); ^ HelloPasteCode.java:3: error: illegal character: '\ufffd' System.out.println(ÔÇ£Hello world!ÔÇ?); ^
…it could do the right thing and just run the copy-pasted code and present the result accordingly. In this context, redirecting STDOUT to a browser window seems approriate:

Of course, not without adding a subtle indicator that we are running in “pasted code quirks mode” at the end. 🤓
PS: To be fair, later in this talk an (unused) slide with well-formed code is rushing by, so there seems to be awareness of the problem somewhere:
