From: <[EMAIL PROTECTED]> > Hi, > > i try to build a xml-document from scratch and write it to a file. > > OutputFormat format = OutputFormat.createPrettyPrint(); > format.setEncoding(this.aEncodingScheme); > XMLWriter writer = new XMLWriter(new FileOutputStream(file), format); > > //XMLWriter writer = new XMLWriter(new FileOutputStream(file)); > > writer.write(doc); > writer.close(); > > This works, but if i try to set an encoding like UTF-8 or UTF-16 or > ISO-8859-1 i got a java.io.UnsupportedEncodingException. > > Anyone have some suggestions?
What platform are you running on? I guess the following code would also fail on your platform also... new OutputStreamWriter( new FileOutputStream(file), "UTF-16" ); as thats effectively the code thats being evaluated. I've explicitly added a JUnit test harness called testEncodingFormats() to the unit test dom4j/src/test/org/dom4j/TestXMLWriter.java. The latest version is in CVS and tests what I think you're trying to do and works fine for me on Win2000 (UK) and JDK1.3 and 1.4. However they fail on JDK1.2.2 for me; UTF-16 is not supported. So I guess proper support for character encoding requires JDK1.3 or later? James > > Frank Weyhers > > PS: I use dom4j 1.3 / Jaxp1.1 > > _______________________________________________ > dom4j-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dom4j-user _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user
