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!
Thank you very much!
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)
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs