views:

212

answers:

6

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

+2  A: 

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.

Borealid
I've added my code in the question...
Stephen
No I haven't - I don't want a google search to turn up the code. Perhaps I will after this round of interviews...
Stephen
+4  A: 

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.)

Jon Skeet
So similar Visual Studio will even warn you not to do this.
Matt Greer
@Matt: Indeed. I've considered logging a feature request for this to be determined by which font you're using. I like the idea of a compiler switch to specify the source font :)
Jon Skeet
Hmmm. nice enough, but I think that one will be too hard to hide - it would end up on internet and in editor... however, it won't have the issues with character encoding (I got a compile error on first try when I it at the command line - needed to specify encoding)
Stephen
+1  A: 

What you need is the Bible.

Use it to secure your own job, not to lower the chances of a newcomer.

Anurag
Or the Obfuscation Table ;) http://forums.thedailywtf.com/forums/p/19103/230329.aspx#230329
Baju
+1  A: 

n-dash or m-dash - look similar to the minus sign.

Mark Bannister
+2  A: 

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
Mark Ransom
+1  A: 

I have actually found something that will work in both UTF-8 and cp1252 encoding (so that it will pass most (all?) text editors): the non breaking space!

Registered at position 160 (00A0, 10100000) in cp1252 and apparently UTF-8 (wikipedia notes it in the range of "Second, third, or fourth byte of a multi-byte sequence"), it provides a character that will "just work"

Note: This has been tested to work on windows when copied out of a text file/skype into code editor. A Wordpress web page did not fare so well (but then it probably changed the character anyhow). Thankfully, our organisation did not pursue the "problems" pre-interview tactic, so I have not tested this definitively on a web page.

Stephen
A lone 0xA0 byte is not valid UTF-8, and of course non-breaking space in UTF-8 is not represented as a lone 0xA0 byte.
R..
That's good to know (+1) - I thought as much. However, for the purpose of this question, it appears to work well (the code compiles and runs correctly - or wrongly)
Stephen
In UTF-8 this would be 0xC2 0xA0, see http://www.fileformat.info/info/unicode/char/a0/index.htm For a web page you might use ` ` instead, but in any case it could be translated to a true space by the browser.
Mark Ransom