Aidan Kehoe <kehoea(a)parhasard.net> wrote:
Ar an seachtú lá déag de mí Aibréan, scríobh Stephen J.
Turnbull>:
> QUERY
>
> >>>>> "Aidan" == Aidan Kehoe <kehoea(a)parhasard.net>
writes:
>
> 2006-04-16 Aidan Kehoe <kehoea(a)parhasard.net>
>
> * lispref/objects.texi (Character Type):
> Describe support for ?\u and ?\U as character escapes allowing you
> to specify the Unicode code point of a character.
>
> What is the purpose of having two syntaxes?
Java does it that way; the idea was to make it comfortable for people coming
from there. That said, allowing variable-length constants and only allowing
the escapes in characters and strings already makes it unfamiliar to Java
people.
What version of Java has the \U escapes? The language specification
says that only lower-case 'u' is a Unicode escape:
http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.3
and that representing supplementary characters requires two consecutive
\u escapes (because Java means "UTF-16" when it says "Unicode").
Indeed, try this experiment with Sun's JDK 1.5.0_06. This code compiles
and prints what is expected when run:
public class Test {
public static void main(String[] args) {
System.out.println("This is a zero: " + '\u0030');
}
}
but this one produces compiler errors:
public class Test {
public static void main(String[] args) {
System.out.println("This is a zero: " + '\U00000030');
}
}
$ javac Test.java
Test.java:3: illegal escape character
System.out.println("This is a zero: " + '\U00000030');
^
Test.java:3: unclosed character literal
System.out.println("This is a zero: " + '\U00000030');
^
Test.java:3: unclosed character literal
System.out.println("This is a zero: " + '\U00000030');
^
Test.java:3: ')' expected
System.out.println("This is a zero: " + '\U00000030');
^
4 errors
(Not that I'm saying it's a bad idea for us to do it that way. I'm just
questioning the claim that Java does it that way.)
Regards,
--
Jerry James, Assistant Professor james(a)xemacs.org
Computer Science Department
http://www.cs.usu.edu/~jerry/
Utah State University