Why?
Browser can translate &#xxxx; into Chinese, but I want to get the real UTF-8 Chinese characters.
Please kindly help, thanks!
Why?
Browser can translate &#xxxx; into Chinese, but I want to get the real UTF-8 Chinese characters.
Please kindly help, thanks!
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 Unicode.
def unescape_numeric_entities(xml) xml.gsub(/&#(\d+);/) do |c| [$1.to_i].pack("U") rescue c end end
unescape_numeric_entities(record.to_xml)
Thank you very much!