Hi all,

Using dom4j 1.6.1.
I have the following XML file (in location data/encoding.xml):
******************************************
<?xml version="1.0"  encoding="UTF-8" ?>
<test>fatigué</test>
******************************************
(in case the e-mail messes up the encoding, the last letter in the
"test" tag is e with an accute accent)

The following JUnit test case fails. Any idea what I'm doing wrong?
For info, the e accute is getting replaced by the characters é (capital
A with tilde, copyright symbol), which are the exactly what you'd get if
you read the UTF-8 character é (e acute) using ISO-8859-1.
*******************************************
import java.io.FileReader;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import junit.framework.TestCase;

public class Dom4jTest extends TestCase {
    private static final Log LOG = LogFactory.getLog(Dom4jTest.class);

    public void testEncoding() throws Exception {
        FileReader fileReader = new FileReader("data/encoding.xml");
        SAXReader saxReader = new SAXReader();
        saxReader.setEncoding("UTF-8");
        Document doc = saxReader.read(fileReader);
        Element root = doc.getRootElement();
        assertEquals("fatigué", root.getStringValue());  
    }
}
*******************************************
Best regards,
Assaf Urieli
Joliciel Informatique
http://www.joli-ciel.com



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to