method
def_uconv_convert_if_can
def_uconv_convert_if_can(meth, to_enc, from_enc, nkf_arg)
public
Hide source
# File lib/rss/converter.rb, line 71 def def_uconv_convert_if_can(meth, to_enc, from_enc, nkf_arg) begin require "uconv" def_convert(1) do |value| "begin\nUconv.\#{meth}(\#{value})\nrescue Uconv::Error\nraise ConversionError.new(\#{value}, \"\#{to_enc}\", \"\#{from_enc}\")\nend\n" end rescue LoadError require 'nkf' if NKF.const_defined?(:UTF8) def_convert(1) do |value| "NKF.nkf(#{nkf_arg.dump}, #{value})" end else def_iconv_convert(to_enc, from_enc, 1) end end end