模块 REXML::Encoding
属性
encoding[R]
ID —> Encoding
名称
公共实例方法
decode(string) 点击切换源码
# File rexml-3.4.0/lib/rexml/encoding.rb, line 29 def decode(string) string.encode(::Encoding::UTF_8, @encoding) end
encode(string) 点击切换源码
# File rexml-3.4.0/lib/rexml/encoding.rb, line 25 def encode(string) string.encode(@encoding) end
encoding=(encoding) 点击切换源码
# File rexml-3.4.0/lib/rexml/encoding.rb, line 7 def encoding=(encoding) encoding = encoding.name if encoding.is_a?(Encoding) if encoding.is_a?(String) original_encoding = encoding encoding = find_encoding(encoding) unless encoding raise ArgumentError, "Bad encoding name #{original_encoding}" end end return false if defined?(@encoding) and encoding == @encoding if encoding @encoding = encoding.upcase else @encoding = 'UTF-8' end true end
私有实例方法
find_encoding(name) 点击切换源码
# File rexml-3.4.0/lib/rexml/encoding.rb, line 34 def find_encoding(name) case name when /\Ashift-jis\z/i return "SHIFT_JIS" when /\ACP-(\d+)\z/ name = "CP#{$1}" when /\AUTF-8\z/i return name end begin ::Encoding::Converter.search_convpath(name, 'UTF-8') rescue ::Encoding::ConverterNotFoundError return nil end name end