module REXML module Encoding @@uconv_available = false ENCODING_CLAIMS = { } def Encoding.claim( encoding_str, match=nil ) if match ENCODING_CLAIMS[ match ] = encoding_str else ENCODING_CLAIMS[ /^\s* Encoding name attr_reader :encoding def encoding=( enc ) enc = UTF_8 unless enc @encoding = enc.upcase require "rexml/encodings/#@encoding" unless @encoding == UTF_8 end def check_encoding str rv = ENCODING_CLAIMS.find{|k,v| str =~ k } # Raise an exception if there is a declared encoding and we don't # recognize it unless rv if str =~ /^\s* 0 encodings |= Dir[ File.join(incl_dir, 'rexml', 'encodings', '*_decl.rb') ] end encodings.collect!{ |f| File.basename(f) } encodings.uniq! end encodings.each { |enc| require "rexml/encodings/#{enc}" } end end