#encoding: utf-8
=begin
将汉字unicode转变成utf-8汉字
=end
s = '外国驻新加坡大使馆/最高专员公署'
def uncode10_to_char string
rs = ''
chars = string.downcase.delete(';').split('&#')
chars[1...chars.length].each{|c|
c = c.to_i.chr((Encoding::UTF_8))
rs += c
}
rs
end
puts s
=begin
将汉字unicode转变成utf-8汉字
=end
s = '外国驻新加坡大使馆/最高专员公署'
def uncode10_to_char string
rs = ''
chars = string.downcase.delete(';').split('&#')
chars[1...chars.length].each{|c|
c = c.to_i.chr((Encoding::UTF_8))
rs += c
}
rs
end
puts s
puts uncode10_to_char(s)
输出结果为
外国驻新加坡大使馆/最高专员公署
外国驻新加坡大使馆/最高专员公署