No way to override default to_xml escaping behavior

All,

I posted this in Rails Talk, and other people have the same issue:

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781/a643a146d8a5645b?lnk=gst&q=to_xml#a643a146d8a5645b

Currently, to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to 'u' and encoding set to 'UTF8', then escaping will NOT be performed."

Unfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output.

Since our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The escaping actually causes client problems. The only way we've found to do this is with the following horrible monkey-patch:

module Builder   class XmlBase     def _escape(text)       text     end   end end

Any ideas on a proper patch? I'm willing to work on it (already working on another patch for timezone stuff with Geoff anyways)

Thanks, Nate

Any ideas on a proper patch? I'm willing to work on it (already working on another patch for timezone stuff with Geoff anyways)

Seems that the fix you have found indicates it's a problem with the builder library more than our own code in to_xml?

Also, what client parser are you using that doesn't know how to normalise those entity references, I believe it's required to be considered a 'compliant' parser?