Sha256: 5756c2904a13b126d8fa0f60fd16086c1d6b8834aa2d4a714b21779c7c41731b
Contents?: true
Size: 1.01 KB
Versions: 12
Compression:
Stored size: 1.01 KB
Contents
# XSD4R - Charset handling with iconv. # # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>. # # This program is copyrighted free software by NAKAMURA, Hiroshi. You can # redistribute it and/or modify it under the same terms of Ruby's license; # either the dual license version in 2003, or any later version. # # PATCH CLONED FROM THIS GITHUB PULL REQUEST https://github.com/felipec/soap4r/pull/6 # unless ''.respond_to? :encode require 'iconv' end module XSD class IconvCharset if ''.respond_to? :encode def self.safe_iconv(to, from, str) str.encode(to, from, :invalid => :replace, :undef => :replace, :replace => '?') end else 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 end end end
Version data entries
12 entries across 12 versions & 1 rubygems