Class | XSD::IconvCharset
In: | xsd/iconvcharset.rb
Parent: | Object

### Methods

safe_iconv

### Public Class methods

safe_iconv(to, from, str)

[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

[Validate]