Skip to content

Differences between XML string encoding in MRI and JRuby #561

@dalton

Description

@dalton

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)} />"

MRI

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

JRuby

  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]).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions