Michel Pigassou
2011-Aug-21 15:36 UTC
Preventing LibXML from encoding all special characters to their html form?
Hi. From what I unsertand, Rails uses by default LibXML. When doing a to_xml, it encodes all special characters, which is useful for <, &, >, etc. but not really for ü, ô, etc. First, I can''t convert them back from ɒ to "û" which is very frustrating for my tests. And I cannot manage to force LibXML not to encode all characters. Any help? Thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/tad49BYg83oJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Michel Pigassou
2011-Aug-21 17:14 UTC
Re: Preventing LibXML from encoding all special characters to their html form?
For those who wonder, the same encoding can be applied this way: require ''builder/xchar'' string.to_xs And to decode, you can do encoded_string.gsub(/\&#([a-f0-9]*);/) { |s| [$1.to_i].pack(''U*'') } Thank you Builder doc! http://rubydoc.info/gems/builder/2.1.2/frames -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/G0elJcGJtFwJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.