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