Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!goblin3!goblin.stu.neva.ru!newsfeed2.funet.fi!newsfeeds.funet.fi!uio.no!ntnu.no!not-for-mail From: Bent C Dalager Newsgroups: comp.lang.java.programmer Subject: Re: CLI Java Glitch Date: Fri, 24 Jun 2011 22:49:40 +0000 (UTC) Organization: Norwegian university of science and technology Lines: 55 Message-ID: References: <4dffe2ea$0$57121$c30e37c6@exi-reader.telstra.net> NNTP-Posting-Host: microbel.pvv.ntnu.no Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: orkan.itea.ntnu.no 1308955780 1209 129.241.210.179 (24 Jun 2011 22:49:40 GMT) X-Complaints-To: usenet@ntnu.no NNTP-Posting-Date: Fri, 24 Jun 2011 22:49:40 +0000 (UTC) User-Agent: slrn/pre1.0.0-18 (Linux) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5658 The below program creates two distinct files on the file system of my OSX 10.6.7, one with a regular hyphen and one with the non-breaking hyphen. Other OS/FS combinations may behave differently. Of course, the two files look exactly the same. In my opinion this is a lot more subtle than a case difference and just underscores that string comparison is a very complicated topic. (This particular sort of subtelty used to be phishing gold, but I believe browser vendors have since implemented countermeasures against that.) I can't offhand think of any characters that are legal in Java symbols and that might also have similarly subtle issues. import java.io.File; import java.io.IOException; public class TestCase { public static void main(String[] args) throws IOException { File fileHyphen = new File("test-file.tmp"); File fileNbrkHyphen = new File("test\u2011file.tmp"); createFile(fileHyphen); createFile(fileNbrkHyphen); } static void createFile(File file) throws IOException { if (!file.createNewFile()) { System.out.println("Could not create " + file); } } } $ javac TestCase.java $ java TestCase $ ls test* test-file.tmp test‑file.tmp $ java TestCase Could not create test-file.tmp Could not create test?file.tmp (not sure what I have misconfigured that bollocksed up the Unicode on that last line) Cheers, Bent D -- Bent Dalager - bcd@pvv.org - http://www.pvv.org/~bcd powered by emacs