Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • xsd/iconvcharset.rb

Parent

Methods

Class/Module Index [+]

Quicksearch

XSD::IconvCharset

Public Class Methods

safe_iconv(to, from, str) click to toggle source
 
               # File 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