XSD::IconvCharset (Class)

In: xsd/iconvcharset.rb
Parent: Object

Methods

Public Class methods

[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 << '?'
      STDERR.puts("Failed to convert #{ch}")
      retry
    end
    return out
  end

[Validate]