views:

164

answers:

3

With the following code:

    System.out.println("\"1. \u20ac\"");
    System.out.println("\"2. Euro sign \u20ac\"");
    System.out.println("\"3. Eurovalue +1,25\u20ac\"");

I get following results:

    "1. €"
    "2. Euro sign €"
    "3. Eurovalue +1,25?€"

Why is there a question mark '?' on row 3. just before the euro (€) sign?

Could someone explain what I am doing wrong? My environment is Windows 7 Eclipse 3.1 with Jre build 1.6.0_18-ea-b05

A: 

It runs fine :)

Padmarag
That's better suited as a comment. It's not really an answer.
Joachim Sauer
A: 

I have executed the code and I got your desired output fine. as below "1. €" "2. Euro sign €" "3. Eurovalue +1,25€"

Since you are getting the wierd output it might be the language setting at your local machine locale settings, That might help you

harigm
Strange if it is encoding because it is escaped. It works really strange depending on which parts I concatenate first, the result is different. If I concatenate first euro sign together with something else and then finally combine it together with a longer string, it works fine.
Martin
+1  A: 

I think I solved it.

In Eclipse there is encoding cp1252 for the java file. It looks the same as ISO-8859-1 but at runtime the result is different. By configuring file encoding to cp1252 it works again.

Really scary :)

Martin