diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-09 22:28:42 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-09 22:28:42 +0000 |
commit | d5fde88a3b2b1e1c8f27e1cbccd7fdafe82a4d84 (patch) | |
tree | c2aa80d7fdd9598fcd612e59d6373f97b893dc21 /lib/rexml/encodings | |
parent | 4ced21cf18d5d85337a1bfcd4d7626b82ac0ae08 (diff) | |
download | ruby-d5fde88a3b2b1e1c8f27e1cbccd7fdafe82a4d84.tar.gz ruby-d5fde88a3b2b1e1c8f27e1cbccd7fdafe82a4d84.tar.xz ruby-d5fde88a3b2b1e1c8f27e1cbccd7fdafe82a4d84.zip |
* eval.c (rb_load): put rb_load_file() in a thread critical
section. [ruby-dev:20490]
* eval.c (compile): put rb_compile_string() in a thread critical
section.
* variable.c (rb_const_get_0): should not warn if constant is not
defined. (ruby-bugs-ja PR#509)
* bignum.c (rb_big2dbl): give a warning on overflow.
(ruby-bugs-ja PR#510)
* util.c (ruby_strtod): change MDMAXEXPT from 511 to 308.
* pack.c (utf8_to_uv): long is sufficient. LONG_LONG is not
required.
* bignum.c (rb_big2str): support 32 bit (without `long long' type)
machines. (ruby-bugs-ja PR#512)
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/encodings')
-rw-r--r-- | lib/rexml/encodings/EUC-JP.rb | 17 | ||||
-rw-r--r-- | lib/rexml/encodings/Shift-JIS.rb | 21 | ||||
-rw-r--r-- | lib/rexml/encodings/Shift_JIS.rb | 18 |
3 files changed, 35 insertions, 21 deletions
diff --git a/lib/rexml/encodings/EUC-JP.rb b/lib/rexml/encodings/EUC-JP.rb index cedd6751e..23a1c3c65 100644 --- a/lib/rexml/encodings/EUC-JP.rb +++ b/lib/rexml/encodings/EUC-JP.rb @@ -13,5 +13,20 @@ begin end end rescue LoadError - raise "uconv is required for Japanese encoding support." + begin + require 'iconv' + module REXML + module Encoding + def from_euc_jp(str) + return Iconv::iconv("utf-8", "euc-jp", str)[0] + end + + def to_euc_jp content + return Iconv::iconv("euc-jp", "utf-8", content)[0] + end + end + end + rescue LoadError + raise "uconv or iconv is required for Japanese encoding support." + end end diff --git a/lib/rexml/encodings/Shift-JIS.rb b/lib/rexml/encodings/Shift-JIS.rb index 865017453..e805456ea 100644 --- a/lib/rexml/encodings/Shift-JIS.rb +++ b/lib/rexml/encodings/Shift-JIS.rb @@ -3,15 +3,30 @@ begin module REXML module Encoding - def to_shift_jis content + def from_shift_jis(str) Uconv::u8tosjis(content) end - def from_shift_jis(str) + def to_shift_jis content Uconv::sjistou8(str) end end end rescue LoadError - raise "uconv is required for Japanese encoding support." + begin + require 'iconv' + module REXML + module Encoding + def from_shift_jis(str) + return Iconv::iconv("utf-8", "shift-jis", str)[0] + end + + def to_shift_jis content + return Iconv::iconv("euc-jp", "shift-jis", content)[0] + end + end + end + rescue LoadError + raise "uconv or iconv is required for Japanese encoding support." + end end diff --git a/lib/rexml/encodings/Shift_JIS.rb b/lib/rexml/encodings/Shift_JIS.rb index 865017453..6e8f75937 100644 --- a/lib/rexml/encodings/Shift_JIS.rb +++ b/lib/rexml/encodings/Shift_JIS.rb @@ -1,17 +1 @@ -begin - require 'uconv' - - module REXML - module Encoding - def to_shift_jis content - Uconv::u8tosjis(content) - end - - def from_shift_jis(str) - Uconv::sjistou8(str) - end - end - end -rescue LoadError - raise "uconv is required for Japanese encoding support." -end +require 'rexml/encodings/Shift-JIS' |