Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a unicode character that looks like an ascii one (but isn't equal)?

Tags:

unicode

ascii

I'm wanting to write an pre-interview question (for java, but that's not important) that has a different answer if you look at it vs if you copy-paste it and run it so that we can check if people actually do the problem manually.

To do this, I'm trying to find a unicode character that will look the same as an ascii character on-screen (so that at some point in my question I can have two methods with the same names but have Integer/int arguments)

I know it's potentially subversive, but I'm hoping it will give an extra metric to validate the other answers.

Note: I've tried the turkish 'i' - it seems to be ascii - is there a unicode version?

Edit/NB: Looks like my intentions were mis-understood... These questions are intended to be done manually, NOT by a compiler. If they're copying the text and compiling then they're bypassing the question, and this is intended to trip them up (or more simply give the wrong answer). The ones that do both will either figure it out, or come to the real interview with confusion that we can help them through.

Final Note: :( this doesn't look like it's really possible - most editors (on windows) will attempt to save in cp1252 (somehow my 1 file was saving as UTF-8) in which case I don't think there's any characters that will work without prompting some sort of save error

like image 248
Stephen Avatar asked Dec 07 '22 02:12

Stephen


2 Answers

You could do something with the same feeling but a slightly less obscure case:

System.out.println(100l);
System.out.println(1001);

Depending on the font used, these two statements can look very similar indeed. (If that's the case with the font you're using, the first number is 100L.)

like image 135
Jon Skeet Avatar answered Jun 13 '23 06:06

Jon Skeet


There are lots of possibilities - here are just a couple that I found with Windows Character Map. Be aware though that not all fonts will have these characters, so your candidate might not see what you intend.

ǃ U+01C3: Latin Letter Retroflex Click
Κ U+039A: Greek Capital Letter Kappa
‚ U+201A: Single Low-9 Quotation Mark
′ U+2032: Prime
like image 36
Mark Ransom Avatar answered Jun 13 '23 07:06

Mark Ransom