Bugs item #1088314, was opened at 2004-12-20 10:43 Message generated for change (Comment added) made by tfromm You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1088314&group_id=16035
Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Thomas Fromm (tfromm) Assigned to: Nobody/Anonymous (nobody) Summary: Character encoding problem on text nodes Initial Comment: happens with dom4j 1.5: e.g. If i add a new Text node containing a string with encoding 8859-1 and add this Text node to an existing document and i want to store the document using outpputformat as UTF-8, then the result document contains text nodes which are still 8859-1. (That produces errors like Invalid byte 2 of 4-byte UTF-8 sequence. when try to parse the document later.) you can try it in this way: OutputFormat of=OutputFormat.createCompactFormat(); of.setEncoding(ENCODING); of.setIndentSize(2); of.setNewlines(true); of.setTrimText(false); doc.getRootElement().add(DocumentHelper.createText("äöü")); XMLWriter xmlWriter = new XMLWriter(fileOutputStream, of); xmlWriter.write(doc); xmlWriter.flush(); fileOutputStream.flush(); fileOutputStream.close(); ... and then try it to read again :-). My solution was to do it in this way: doc.getRootElement().add(DocumentHelper.createText(new String("äöü".getBytes(ENCODING)))); But if i want to store document in several encodings, then i have a problem again :-) ---------------------------------------------------------------------- >Comment By: Thomas Fromm (tfromm) Date: 2004-12-20 11:06 Message: Logged In: YES user_id=79402 I tested it with 1.5.2 and problem still exists. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1088314&group_id=16035 ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ dom4j-dev mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-dev