I don't have 0.3x on my system anymore, but I do not think UTF16 will behave any differently. .to_s is written incorrectly, from what I can tell, since it just feeds the encoding of the document back into the formatter. But in either case, if you want the as-encoded document, you really want to use doc.dump.
Encoding has never worked correctly within the library. It only functions properly when fed UTF-8 as I have had to employ Iconv for anything else. Dan On Nov 26, 2007, at 16:05, Tim Perrett wrote: > Hey Chaps > > There seems to be some kind of issue with UTF-16 encoding in libxml- > ruby version 0.5.2.0. > > When I do this: > > doc = XML::Document.new() > # doc.encoding = 'utf-16' > doc.root = XML::Node.new('root_node') > root = doc.root > puts doc > ## => <?xml version="1.0"?><root_node/> > > Uncomment the encoding however and you get this: > > doc = XML::Document.new() > doc.encoding = 'utf-16' > doc.root = XML::Node.new('root_node') > root = doc.root > puts doc > ## => ÿþ< > > Any idea whats going on here and how to fix it? The encoding features > used to work no problem at all. Im running ruby 1.8.6 (2007-06-07 > patchlevel 36) [universal-darwin9.0] > > Cheers > > Tim > > > _______________________________________________ > libxml-devel mailing list > libxml-devel@rubyforge.org > http://rubyforge.org/mailman/listinfo/libxml-devel _______________________________________________ libxml-devel mailing list libxml-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/libxml-devel