mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rss/converter.rb: changed to try to use Iconv for default
conversion. * lib/rss/rss.rb: 0.0.9 -> 0.1.0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
abc8e89324
commit
3f5c0f4f6f
3 changed files with 16 additions and 8 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Sat Oct 9 21:23:37 2004 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
|
* lib/rss/converter.rb: changed to try to use Iconv for default
|
||||||
|
conversion.
|
||||||
|
|
||||||
|
* lib/rss/rss.rb: 0.0.9 -> 0.1.0.
|
||||||
|
|
||||||
Sat Oct 9 19:50:36 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Oct 9 19:50:36 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* io.c (rb_io_getline): should not treat char as negative value.
|
* io.c (rb_io_getline): should not treat char as negative value.
|
||||||
|
|
|
@ -7,14 +7,15 @@ module RSS
|
||||||
include Utils
|
include Utils
|
||||||
|
|
||||||
def initialize(to_enc, from_enc=nil)
|
def initialize(to_enc, from_enc=nil)
|
||||||
to_enc = to_enc.downcase.gsub(/-/, '_')
|
normalized_to_enc = to_enc.downcase.gsub(/-/, '_')
|
||||||
from_enc ||= 'utf-8'
|
from_enc ||= 'utf-8'
|
||||||
from_enc = from_enc.downcase.gsub(/-/, '_')
|
normalized_from_enc = from_enc.downcase.gsub(/-/, '_')
|
||||||
if to_enc == from_enc
|
if normalized_to_enc == normalized_from_enc
|
||||||
def_same_enc()
|
def_same_enc()
|
||||||
else
|
else
|
||||||
if respond_to?("def_to_#{to_enc}_from_#{from_enc}")
|
def_diff_enc = "def_to_#{normalized_to_enc}_from_#{normalized_from_enc}"
|
||||||
send("def_to_#{to_enc}_from_#{from_enc}")
|
if respond_to?(def_diff_enc)
|
||||||
|
__send__(def_diff_enc)
|
||||||
else
|
else
|
||||||
def_else_enc(to_enc, from_enc)
|
def_else_enc(to_enc, from_enc)
|
||||||
end
|
end
|
||||||
|
@ -40,9 +41,9 @@ module RSS
|
||||||
def def_iconv_convert(to_enc, from_enc, depth=0)
|
def def_iconv_convert(to_enc, from_enc, depth=0)
|
||||||
begin
|
begin
|
||||||
require "iconv"
|
require "iconv"
|
||||||
|
@iconv = Iconv.new(to_enc, from_enc)
|
||||||
def_convert(depth+1) do |value|
|
def_convert(depth+1) do |value|
|
||||||
<<-EOC
|
<<-EOC
|
||||||
@iconv ||= Iconv.new("#{to_enc}", "#{from_enc}")
|
|
||||||
begin
|
begin
|
||||||
@iconv.iconv(#{value})
|
@iconv.iconv(#{value})
|
||||||
rescue Iconv::Failure
|
rescue Iconv::Failure
|
||||||
|
@ -56,7 +57,7 @@ module RSS
|
||||||
end
|
end
|
||||||
|
|
||||||
def def_else_enc(to_enc, from_enc)
|
def def_else_enc(to_enc, from_enc)
|
||||||
raise UnknownConversionMethodError.new(to_enc, from_enc)
|
def_iconv_convert(to_enc, from_enc, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
def def_same_enc()
|
def def_same_enc()
|
||||||
|
|
|
@ -56,7 +56,7 @@ require "rss/xml-stylesheet"
|
||||||
|
|
||||||
module RSS
|
module RSS
|
||||||
|
|
||||||
VERSION = "0.0.9"
|
VERSION = "0.1.0"
|
||||||
|
|
||||||
URI = "http://purl.org/rss/1.0/"
|
URI = "http://purl.org/rss/1.0/"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue