summaryrefslogtreecommitdiff
path: root/lib/rss/converter.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-17 10:13:25 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-17 10:13:25 +0000
commit966a25465aab5c2972e6c453f631a15fc2223256 (patch)
tree847090e856c9901ab2cc19251c179b9b0985e65b /lib/rss/converter.rb
parent53cbab048452742b537ac8bccf494630d1c184c8 (diff)
* lib/rss, test/rss:
- supported Atom. - bumped version 0.1.6 to 0.1.7. * sample/rss/convert.rb: added new sample. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rss/converter.rb')
-rw-r--r--lib/rss/converter.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/rss/converter.rb b/lib/rss/converter.rb
index 7ad79db318..415a319188 100644
--- a/lib/rss/converter.rb
+++ b/lib/rss/converter.rb
@@ -66,7 +66,7 @@ module RSS
end
end
- def def_uconv_convert_if_can(meth, to_enc, from_enc)
+ def def_uconv_convert_if_can(meth, to_enc, from_enc, nkf_arg)
begin
require "uconv"
def_convert(1) do |value|
@@ -79,24 +79,31 @@ module RSS
EOC
end
rescue LoadError
- def_iconv_convert(to_enc, from_enc, 1)
+ 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
def def_to_euc_jp_from_utf_8
- def_uconv_convert_if_can('u8toeuc', 'EUC-JP', 'UTF-8')
+ def_uconv_convert_if_can('u8toeuc', 'EUC-JP', 'UTF-8', '-We')
end
def def_to_utf_8_from_euc_jp
- def_uconv_convert_if_can('euctou8', 'UTF-8', 'EUC-JP')
+ def_uconv_convert_if_can('euctou8', 'UTF-8', 'EUC-JP', '-Ew')
end
def def_to_shift_jis_from_utf_8
- def_uconv_convert_if_can('u8tosjis', 'Shift_JIS', 'UTF-8')
+ def_uconv_convert_if_can('u8tosjis', 'Shift_JIS', 'UTF-8', '-Ws')
end
def def_to_utf_8_from_shift_jis
- def_uconv_convert_if_can('sjistou8', 'UTF-8', 'Shift_JIS')
+ def_uconv_convert_if_can('sjistou8', 'UTF-8', 'Shift_JIS', '-Sw')
end
def def_to_euc_jp_from_shift_jis