method

safe_iconv

Importance_0
v1_8_7_72 - Show latest stable - 0 notes - Class: XSD::IconvCharset
safe_iconv(to, from, str) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# 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
Register or log in to add new notes.