James Moore
2007-Oct-15 21:59 UTC
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>Ä</x> </foo> {"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 Moore | james-7AXNjMB9LsNl57MIdRCFDg@public.gmane.org Ruby and Ruby on Rails consulting blog.restphone.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---