Unexpected results from roundtrip through ActiveResource to_xml/from_xml - string isn't the same?

I’m trying to figure out why I get a different string after a
round-trip through to_xml/from_xml. I’m using edge rails, rev is
7921, and I see the same results on Windows and Linux.

Here’s the code:

require File.dirname(FILE) + ‘/…/config/boot’
require RAILS_ROOT + ‘/config/environment’

class Foo < ActiveResource::Base
self.site = “http://localhost
end

f = Foo.new(:x => “\304”)
puts f.to_xml
results = Hash.from_xml(f.to_xml)
puts results.inspect
puts "Value for character in original: #{f.x[0]}; "
puts “Value for character after round-trip through xml:
#{results[‘foo’][‘x’][0]}”

And here’s the result:

<?xml version="1.0" encoding="UTF-8"?> Ä {"foo"=>{"x"=>"Ä"}} Value for character in original: 196; Value for character after round-trip through xml: 195

Shouldn’t that last 195 be 196?


James M. | [email protected]
Ruby and Ruby on Rails consulting
blog.restphone.com