summaryrefslogtreecommitdiff
path: root/lib/rexml/encodings/EUC-JP.rb
diff options
context:
space:
mode:
authorser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-19 03:51:53 +0000
committerser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-19 03:51:53 +0000
commited512acb2fd71016e320414a16b3262ce2f9c366 (patch)
tree2e3a631d82871b691dc1a7c0633033fa04ff8d2f /lib/rexml/encodings/EUC-JP.rb
parentd4d497dd86962d333337b70392623ccde5a053c2 (diff)
Cross-ported the REXML changes from HEAD to the 1.8 branch.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/encodings/EUC-JP.rb')
-rw-r--r--lib/rexml/encodings/EUC-JP.rb41
1 files changed, 12 insertions, 29 deletions
diff --git a/lib/rexml/encodings/EUC-JP.rb b/lib/rexml/encodings/EUC-JP.rb
index a1314d0856..684df0bbd6 100644
--- a/lib/rexml/encodings/EUC-JP.rb
+++ b/lib/rexml/encodings/EUC-JP.rb
@@ -1,37 +1,20 @@
-begin
- require 'iconv'
+require 'uconv'
- module REXML
- module Encoding
- @@__REXML_encoding_methods =<<-EOL
- def decode(str)
- return Iconv::iconv("utf-8", "euc-jp", str)[0]
- end
-
- def encode content
- return Iconv::iconv("euc-jp", "utf-8", content)[0]
- end
- EOL
+module REXML
+ module Encoding
+ def decode_eucjp(str)
+ Uconv::euctou8(str)
end
- end
-rescue LoadError
- begin
- require 'uconv'
- module REXML
- module Encoding
- @@__REXML_encoding_methods =<<-EOL
- def decode(str)
- return Uconv::euctou8(str)
- end
+ def encode_eucjp content
+ Uconv::u8toeuc(content)
+ end
- def encode content
- return Uconv::u8toeuc(content)
- end
- EOL
+ register("EUC-JP") do |obj|
+ class << obj
+ alias decode decode_eucjp
+ alias encode encode_eucjp
end
end
- rescue LoadError
- raise "uconv or iconv is required for Japanese encoding support."
end
end