Comment Illegal Unicode Sequences

I once worked on a Java application that handles Unicode processing, and as usual, I write code and test it first, then comment out the working code and add a few new lines. This process continues until I find a solution.

The exact problem I ran into was commenting on illegal Unicode strings. Some unicode didn't work, and I just wanted to comment on this. To my complete surprise, this did not work.

Code example:

class UnicodeTester{
//char someCharacter = "\ux13d";
}

javac UnicodeTester.java

UnicodeTester.java:2: illegal unicode escape
//char someCharacter = "\ux13d";
                              ^
1 error

Is there a way so that I can comment on illegal Unicode sequences? I read the Java Language Specification 2.2 and 2.3, The lexical grammar is put in place before the syntax grammar. TIME But what is the most effective workaround besides removing them from the source code?

+3
2

, char :

//char someCharacter = "\ ux13d";
+1

, -, PHP- Javascript, , , PHP , PHP- JS .

-

class UnicodeTester{
//char someCharacter = "\\ux13d";  // illegal
}

grep \u grep illegal.

+1

Source: https://habr.com/ru/post/1769875/


All Articles