I was once working on a Java application dealing with unicode processing – and as usual to begin with, I write some code and test it, then comment out the working code and add some new lines., and this process goes on till I find the solution
The exact issue I had was commenting out illegal Unicode strings. Some unicode wasn’t working and I wanted to just comment it out.. to my utter surprise, it wouldn’t work.
Example Code:
class UnicodeTester{
//char someCharacter = "\ux13d";
}
javac UnicodeTester.java
UnicodeTester.java:2: illegal unicode escape
//char someCharacter = "\ux13d";
^
1 error
Is there a way where I can comment out illegal unicode sequences?? I read the Java Language Specification 2.2 & 2.3, The Lexical Grammar is enforced before the Syntactic Grammar. PERIOD. But what is the most effective workaround other than removing them from the source code??
You could work around it by inserting a space char after the backslash: