Re: illegal line end in character literal in escaped unicode CARRIAGERETURN / NEW LINE

Discussion in 'Java' started by Lew, May 15, 2009.

  1. Lew

    Lew Guest

    On May 15, 9:51 am, Christian <> wrote:
    > Hi folks,
    >
    > I just stumbled replacing an escaped Unicode of CARRIAGE RETURN / NEW
    > LINE and got a compiler-error "illegal line end in character literal"
    > for
    >
    > switch (original)
    > {
    >         case '\u000D' : return '\u0020';


    use less wide indentation, please.

    >         case '\u000A' : return '\u0020';
    >
    > }
    >
    > To be honest: I don't have the slightest idea what the compiler is
    > complaining about. The escape-sequence \u seems to be correct
    > according to most of the sources I came across and the two-digited
    > hexadecimal encoding cannot be wrong - so what's up here?


    You ended the line after the keyword 'case' without giving it a
    constant. Bear in mind that Unicode escape sequences are substituted
    prior to parsing the source, so for example, your second 'case' is
    exactly equivalent to:

    case '
    ' : return ' ';

    Do you see how that is not a legal Java syntax?

    --
    Lew
    Lew, May 15, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chason Hayes

    Literal Escaped Octets

    Chason Hayes, Feb 6, 2006, in forum: Python
    Replies:
    11
    Views:
    668
    Chason Hayes
    Feb 8, 2006
  2. Jonathan Ballet

    xmlrpclib and carriagereturn (\r)

    Jonathan Ballet, Mar 17, 2006, in forum: Python
    Replies:
    5
    Views:
    350
    Jonathan Ballet
    Mar 18, 2006
  3. Andreas Leitgeb
    Replies:
    0
    Views:
    438
    Andreas Leitgeb
    May 15, 2009
  4. Mark Space
    Replies:
    0
    Views:
    471
    Mark Space
    May 15, 2009
  5. Joshua Cranmer
    Replies:
    0
    Views:
    451
    Joshua Cranmer
    May 15, 2009
Loading...

Share This Page