Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

illegal unicode escape

 
Brajmohan Jangir
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could work around it by inserting a space char after the backslash
 
Brajmohan Jangir
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic