Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Differences between XML string encoding in MRI and JRuby #561

dalton opened this Issue · 3 comments

5 participants


I'd like to use JRuby to create some XML files, but it is not escaping characters in the same way MRI Ruby does.

> "<node attr=#{'this is "my" complicated <String>'.encode(:xml => :attr)} />"


  ruby-1.9.3-p194 => "<node attr=\"this is &quot;my&quot; complicated &lt;String&gt;\" />"


  jruby-1.7.2 => "<node attr=this is \"my\" complicated <String> />"

This is a contrived example to show the differences between the two Ruby implementations of String#encode(:xml => [attr|text]).


Yeah. Unfortunately, this is a known problem. We accept the option but it is current unimplemented. I do think we have an issue open for this but I cannot locate it atm (so I will leave this open). The good news is that some recent refactoring will make fixing this a little bit easier, but we are not specifically working on it. For sure if this is not addressed for 1.7.4 it will be for 1.7.5.


This was fixed by #684 and should be available in 1.7.4.

@atambo atambo closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.