Class: XSD::IconvCharset
- Inherits:
-
Object
- Object
- XSD::IconvCharset
- Defined in:
- lib/xsd/iconvcharset.rb
Class Method Summary collapse
Class Method Details
.safe_iconv(to, from, str) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/xsd/iconvcharset.rb', line 16 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 |