aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Illegal character ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Illegal character ??" Watch "Illegal character ??" New topic
Author

Illegal character ??

srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252
hi friends ,

i have some doubt in this declaration i.e..

char a = '\u000A' why is giving output as Illegal character ???

thanks

srikanth


Thanks & Regards<br /> <br />-Srikanth
madhu cm
Greenhorn

Joined: Jun 26, 2005
Posts: 20
To clear your doubt....
visit this page <

http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter09/characterEncodng.html
[ September 09, 2005: Message edited by: madhu cm ]
Raghu Shree
Ranch Hand

Joined: Mar 18, 2005
Posts: 143
when we compile the java file the source is converted from default encoding to unicode. At that time unicode chars like \Uxxx are replaced with the
corresponding character. After that the source file is compiled. Here \u000a is a new line character like '\n'.

so String newline="\u000A" would be replaced like below
newline="
";


So compiler shows the error message unclosed string literal


Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="http://groups.yahoo.com/group/scjp_share" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="http://groups.yahoo.com/group/JavaBeat_SCWCD" target="_blank" rel="nofollow">SCWCD Group</a>
madhu cm
Greenhorn

Joined: Jun 26, 2005
Posts: 20
Unicode escape characters, of the form '\Uxxxx', where xxxx is a hexadecimal value, are processed very early in the translation process (See JLS ?3.10.4). As a result, the special characters '0A', line feed and '0D', carriage return are interpreted literally as 'end of line'.
The expression:

char A = '\u000A';


therefore becomes

char A =;


which results in a compile-time error.
To avoid this error, always use the special escape characters '\n' (line feed) and '\r' (carriage return);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Illegal character ??