my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes illegal unicode escape Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "illegal unicode escape" Watch "illegal unicode escape" New topic
Author

illegal unicode escape

Brajmohan Jangir
Greenhorn

Joined: Apr 17, 2012
Posts: 3

public class Hello{
//Commented character '\uFF'
}

Compiler shows me "illegal unicode escape".
Please can you explain me why compiler looks inside commented code?

I am working on Windows and using jdk 1.6.

Thanks in Advance.
Pondurai Singh
Ranch Hand

Joined: Jun 27, 2011
Posts: 35
You could work around it by inserting a space char after the backslash


Software Developer, Oracle Java Certification Training Labs at EPractize Labs.
Brajmohan Jangir
Greenhorn

Joined: Apr 17, 2012
Posts: 3
Thanks a lot for quick response.
I really appreciate your answer.

But I am looking for the cause of this compilation failure.
Why this comment fails the compilation?
Pondurai Singh
Ranch Hand

Joined: Jun 27, 2011
Posts: 35
Unicode Escapes

A compiler for the Java programming language ("Java compiler") first recognizes Unicode escapes in its input, translating the ASCII characters \u followed by four hexadecimal digits to the UTF-16 code of the indicated hexadecimal value, and passing all other characters unchanged. Representing supplementary characters requires two consecutive Unicode escapes. This translation step results in a sequence of Unicode input characters.



In addition to the processing implied by the grammar, for each raw input character that is a backslash \, input processing must consider how many other \ characters contiguously precede it, separating it from a non-\ character or the start of the input stream. If this number is even, then the \ is eligible to begin a Unicode escape; if the number is odd, then the \ is not eligible to begin a Unicode escape.
Brajmohan Jangir
Greenhorn

Joined: Apr 17, 2012
Posts: 3
I got the reason.
It means compiler tries to translate the ASCII characters \u followed by hexadecimal digits to UTF-16 code and if compiler founds any illegal Unicode escape then it fails.

Thank you very much...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: illegal unicode escape
 
Similar Threads
regexp : escape sequences in string
New SCJP mock exam
unicode erro
Comment Statement
Start study for SCJP