Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting EURO Symbol from XMl file returns '?'

416044Nov 10 2005 — edited Nov 15 2005
When I read an element value (via Java XPath API) that contains the EURO currency symbol (�), I just get a '?' instead of the currency symbol. I tried to convert the string via severeal methods:
<?xml version="1.0" encoding="iso-8859-1"?>
...
<numberformat>� #,###.00</numberformat>
                    System.out.println("bytes: "+result.getBytes());
                    System.out.println("file encoding: "+System.getProperty("file.encoding")); //prints "Cp1252"
                    System.out.println("1st: "+new String(result.getBytes(), "UTF-8"));
                    System.out.println("1st: "+new String(result.getBytes("ISO-8859-1"), "UTF-8"));
                    System.out.println("1st: "+new String(result.getBytes("Cp1252"), "UTF-8"));
                    System.out.println("1st: "+new String(result.getBytes("UTF-8"), "UTF-8"));
                    
                    System.out.println("1st: "+new String(result.getBytes(), "Cp1252"));
                    System.out.println("1st: "+new String(result.getBytes("ISO-8859-1"), "Cp1252"));
                    System.out.println("1st: "+new String(result.getBytes("Cp1252"), "Cp1252"));
                    System.out.println("1st: "+new String(result.getBytes("UTF-8"), "Cp1252"));
                    
                    System.out.println("1st: "+new String(result.getBytes(), "ISO-8859-1"));
                    System.out.println("1st: "+new String(result.getBytes("ISO-8859-1"), "ISO-8859-1"));
                    System.out.println("1st: "+new String(result.getBytes("Cp1252"), "ISO-8859-1"));
                    System.out.println("1st: "+new String(result.getBytes("UTF-8"), "ISO-8859-1"));
But the output is always a '?' at the place of the currency symbol instead of '�'. Is there another way to somehow convert it back?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 13 2005
Added on Nov 10 2005
8 comments
435 views