Is there a unicode character that looks like an ascii one (but isn't equal)?
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 confusio开发者_StackOverflown 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
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.)
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
Try a cyrillic character such as 'a' or 's'. Take a look: http://jrgraphix.net/research/unicode_blocks.php?block=8
Good idea, by the way, but I wouldn't do a method-overloading answer. I'd use a switch-case iterating over a string. That way there's no tip-off that something is wrong, and you can easily pick out the candidates who really know their stuff.
n-dash or m-dash - look similar to the minus sign.
The Unicode Consortium has a page dedicated to Confusables: http://unicode.org/cldr/utility/confusables.jsp
That shows there are plenty of Unicode characters that look similar to an ASCII one:
Similar to I:
精彩评论