But for
char c = '\u0008';
which is the unicode value for backspace, and gets translated to
char c = ';
why doees the compiler not flag any error?
What about
char d = '\u000c';
which is the unicode value for formfeed, why does the compiler not flag an error in the above case also?
char c = '\u0008' is not translated to the mentioned expression. Simply the compiler doesn't do that.
JLS 3.3 says that all the Unicode escapes will be translated to the corresponding Unicode character.
For instance \u0041 will be tranlated to A. The purpose of this lexical translation is to allow the text editors that doen't support Unicode to produce Unicode characters. Because all the symbols in a Unicode escape are ASCII, and all editors manage ASCII.
JLS 3.4 says that the next lexical translation is to recognize the line terminator characters:
\n (Unix), \r (Mac) and \r\n (Windows)
Doing so the lines of the program are determined.
Because the line terminators are processed at this step they are not allowed to be be part of character or
string literals, as it is stated in JLS 3.10.4 y 3.10.4
Also note that in JLS 3.4 only line terminators are recognized. The rest of the Unicode characters are left untouched. And they can appear within string or character literal with the logical exceptions of '
""
\