So "\u1234" creates a string with one character '\u1234' in it. "\uu1234" however creates the string "\u1234" with 6 characters in it. The "\uu" sequence gets turned into "\u". This is intentional, as the code in the lexer says
/* A double-u quoted escape. Convert the "\u" or "\U" to "", * thereby shaving off a "u" or "U" from the escape * sequence. */
Where does this weird syntax come from? Why is it desired?
Where does this weird syntax come from? Why is it desired?
See section 3.3 of http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html
The intention is clearer when you have more than two levels of quoting. cf
Level ""-escapes Double-U 1 "\u1234" "\u1234" 2 "\u1234" "\uu1234" 3 "\\u1234" "\uuu1234" 4 "\\\\u1234" "\uuuu1234" ... n ""*(1<<(n-1))+"u1234" ""+"u"*n+"1234"
pike-devel@lists.lysator.liu.se