Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?B?Sm9zaHVhIENyYW5tZXIg8J+Qpw==?= Newsgroups: comp.lang.java.programmer Subject: Re: java code Date: Sat, 22 Feb 2014 12:05:14 -0600 Organization: A noiseless patient Spider Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 22 Feb 2014 18:05:21 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="8b6ddcc38ecbed2f71b30fabadb8aa0b"; logging-data="7446"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ezAu+yFDtSFRq94uusafOF7ElpaQ2grs=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Thunderbird/27.0 In-Reply-To: Cancel-Lock: sha1:ikQSZaX8/fnkGMDkPTsYk8f2+Ag= Xref: csiph.com comp.lang.java.programmer:27572 On 2/22/2014 6:57 AM, Stuart wrote: > At first, this code wouldn't run because for some reasons Thunderbird > treated the K in the lines > char[] K = new char[256]; > and the first K in this line > int K = 0, Κ = 0; > both as 0x4B, thus making the code erroneous. Or maybe it was one of the > newsservers that made the substitution. Looking at your newspost in a mojibaked output: > char[] K = new char[256]; > int K = 0, Κ = 0; So the actual newsgroup text was transported without normalization. Running some tests, it appears that U+212A KELVIN SYMBOL gets normalized to the ASCII K under NFC (I thought it was NFKC), which means that either pasting from the clipboard to your IDE or your actual Java compiler is doing some NFC normalization. I suppose you could distinguish the two by seeing if the ASCII K can refer to a variable called \u212a (Unicode escapes are legal outside of strings in Java). > I never knew that Java allowed Unicode letters in the source code, so I > even learned something new today. And now you learn a little about Unicode normalization. :-) -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth