Class: XSD::IconvCharset
Class Method Summary collapse
Class Method Details
.safe_iconv(to, from, str) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/xsd/iconvcharset.rb', line 17 def self.safe_iconv(to, from, str) iconv = Iconv.new(to, from) out = "" begin out << iconv.iconv(str) rescue Iconv::IllegalSequence => e out << e.success ch, str = e.failed.split(//, 2) out << '?' warn("Failed to convert #{ch}") retry end return out end |