Forum: Ruby on Rails Chinese characters become to &#3342 after "to_xml"

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2f8ebdb9e06423a06481ad178a7fdc27?d=identicon&s=25 Datou (Guest)
on 2007-05-14 07:26
(Received via mailing list)

Browser can translate &#xxxx; into Chinese, but I want to get the real
UTF-8 Chinese characters.

Please kindly help, thanks!
8bc543795b502900b5333aea73ad5533?d=identicon&s=25 Eden Li (edenli)
on 2007-05-15 05:26
(Received via mailing list)
It's built into Builder::XmlMarkup.  You can run a transform on the
returned XML to un-escape characters that are encoded into numbers.
This assumes that all characters from emitted from #to_xml were

def unescape_numeric_entities(xml)
  xml.gsub(/&#(\d+);/) do |c|
    [$1.to_i].pack("U") rescue c

2f8ebdb9e06423a06481ad178a7fdc27?d=identicon&s=25 Datou (Guest)
on 2007-05-15 09:45
(Received via mailing list)
Thank you very much!
This topic is locked and can not be replied to.