This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Product Version = NetBeans IDE 8.0.2 (Build 201408251540) Operating System = Linux version 3.16.7-7-desktop running on amd64 Java; VM; Vendor = 1.8.0_20 Runtime = Java HotSpot(TM) 64-Bit Server VM 25.20-b23 public static void main(String[] args) { CharSequence target = "\u000b"; // NB is fine with this CharSequence source = "\u000a"; // NB thinks the second quote is missing ... }
I have just discovered the same misbehaviour with ... CharSequence source = "\u0000d"; // NB thinks second quote is missing for Carriage Return too.
This is as java behaves. The unicode are translated to related character at first, see http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html
> This is as java behaves. The unicode are translated to related character at first, > see http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html I have not described the problem clearly enough. I am writing a program that takes a string and swaps control characters for printable characters. The NB editor will not let me declare a CharSequence that contains a single escaped character equivalent to the unicode representation for \n. The NB editor misbehaves. The NB also misbehaves if I try to declare a CharSequence assigned to a string containing a string with an escaped unicode character for \r, which is \u000d.
I understand the problem, but the "\u000d" or "\u000a" is not valid code, try to compile the code from command line and you'll see the compilation error as well. The reason is described in the java language specification which was provided in comment 2
> I understand the problem, but the "\u000d" or "\u000a" is not valid code, try to compile the code from command line and you'll see the compilation error as well. > The reason is described in the java language specification which was provided in comment 2 Thank you for your guidance. I will reread 3.3 Unicode Escapes to discover whether one can use a unicode escape to insert a newline character into a string. I'll stop when my head hurts.
The unicode escape sequences are translated to "regular" unicode characters at an early compilation stage (by the java lexer) so simply said the compiler itself only sees physical newline character regardless of whether it was entered as \u000a in the source or whether a regular newline character was present in the source.
Thank you. I have now discovered some weird code snippets that make my misunderstanding very clear. The following came from Mark Peters on stackoverflow public class FalseIsTrue { public static void main(String[] args) { if ( false == true ) { //these characters are magic: \u000a\u007d\u007b System.out.println("false is true!"); } } }