Ruby 发送请求时,Rails 3 ActiveResource未在xml中转义unicode

Ruby 发送请求时,Rails 3 ActiveResource未在xml中转义unicode,ruby,ruby-on-rails-3,activeresource,activesupport,Ruby,Ruby On Rails 3,Activeresource,Activesupport,我们最近转向了rails 3.2.13。我们使用ActiveResource调用web服务。ActiveResource将生成xml负载。我们注意到新的xml没有转义unicode字符。例如: <name> C:\Documents and Settings\All Users\testütestdev1.txt </name> <name> C:\Documents and Settings\All Users\testütestdev1.txt</name>

我们最近转向了rails 3.2.13。我们使用ActiveResource调用web服务。ActiveResource将生成xml负载。我们注意到新的xml没有转义unicode字符。例如:

<name> C:\Documents and Settings\All Users\testütestdev1.txt </name> <name> C:\Documents and Settings\All Users\testütestdev1.txt</name> 在rails 2.3中,它将逃逸到ü;:

<name> C:\Documents and Settings\All Users\testü;testdev1.txt<name>
经过一些调查。这似乎是由于ActiveSupport to_xml方法没有转义unicode字符。有人遇到过这个问题并且知道如何解决吗?

您可以使用
Rack::Utils

> Rack::Utils.escape("  <name> C:\Documents and Settings\All Users\testütestdev1.txt </name>")
#=> "++%3Cname%3E+C%3ADocuments+and+SettingsAll+Users%09est%C3%BCtestdev1.txt+%3C%2Fname%3E"

> Rack::Utils.unescape(_)
#=> "  <name> C:Documents and SettingsAll Users\testütestdev1.txt </name>"
>Rack::Utils.escape(“C:\Documents and Settings\All Users\testütestdev1.txt”)
#=>“++%3Cname%3E+C%3Documents+和+SettingsAll+用户%09est%C3%BCtestdev1.txt++%3C%2Fname%3E”
>框架::Utils.unescape(389;)
#=>“C:文档和设置所有用户\testütestdev1.txt”

但问题是我们自己无法进行转义,因为我们正在使用活动资源进行web服务调用,该调用将生成xml。
> Rack::Utils.escape("  <name> C:\Documents and Settings\All Users\testütestdev1.txt </name>")
#=> "++%3Cname%3E+C%3ADocuments+and+SettingsAll+Users%09est%C3%BCtestdev1.txt+%3C%2Fname%3E"

> Rack::Utils.unescape(_)
#=> "  <name> C:Documents and SettingsAll Users\testütestdev1.txt </name>"