[Ruby 1.9-Bug#3990][Assigned] tests of rexml/rss reports many errors and failures without iconv

Bug #3990: tests of rexml/rss reports many errors and failures without
iconv
http://redmine.ruby-lang.org/issues/show/3990

$B5/I<<T(B: Usaku NAKAMURA
$B%9%F!<%?%9(B: Assigned, $BM%@john(B: Normal
$BC4Ev<T(B: Kouhei S., $B%+%F%4%j(B: lib, Target version: 1.9.x
ruby -v: ruby 1.9.3dev (2010-10-27 trunk 29612) [x64-mswin64_100]

iconv.so$B$,$J$$4D6-$G(Btest-all$B$r<B9T$9$k$H!"(Brexml$B$H(Brss$B$N%F%9%H$G(B
$B7k9=$J?t$N(BE$B$H(BF$B$,H/@8$7$^$9!#(B
$B$R$I$$%F%9%H$K$J$k$H(B require “iconv” $B$H$+$$$-$J$j=q$$$F$"$C$?$j(B
$B$H$+$7$^$9!#(B

[email protected]$H(Biconv$B$r;H$&I,[email protected]$,$[$H$s$I$J$$$H;W$&$N$G$9$,!"(B
$B$I$&$G$7$g$&$+(B?($BBe$o$j$K(BString#encode$B$r;H$&(B)
$B$=$l$,3p$o$J$$$J$i!"$;$a$F%F%9%H$G(Biconv$BI,?$J$b$N$O(Biconv$B$,$J$$$J$i(B
skip$B$9$k$h$&$K$7$F$[$7$$$G$9!#(B

iconv.so$B$,$J$$4D6-$G(Btest-all$B$r<B9T$9$k$H!"(Brexml$B$H(Brss$B$N%F%9%H$G(B
$B7k9=$J?t$N(BE$B$H(BF$B$,H/@8$7$^$9!#(B
$B$R$I$$%F%9%H$K$J$k$H(B require “iconv” $B$H$+$$$-$J$j=q$$$F$"$C$?$j(B
$B$H$+$7$^$9!#(B

[email protected]$H(Biconv$B$r;H$&I,[email protected]$,$[$H$s$I$J$$$H;W$&$N$G$9$,!"(B
$B$I$&$G$7$g$&$+(B?($BBe$o$j$K(BString#encode$B$r;H$&(B)
$B$=$l$,3p$o$J$$$J$i!"$;$a$F%F%9%H$G(Biconv$BI,?$J$b$N$O(Biconv$B$,$J$$$J$i(B
skip$B$9$k$h$&$K$7$F$[$7$$$G$9!#(B

$B=5Kv$K$G$b$=$s$J46$8$K$7$F$$-$^$9!(B

[email protected]$G$9!#(B

At Wed, 27 Oct 2010 20:48:08 +0900,
Usaku NAKAMURA wrote in [ruby-dev:42464]:

[email protected]$H(Biconv$B$r;H$&I,[email protected]$,$[$H$s$I$J$$$H;W$&$N$G$9$,!"(B
$B$I$&$G$7$g$&$+(B?($BBe$o$j$K(BString#encode$B$r;H$&(B)

$B$5$C$/$j(Bext/iconv$B:o=|$7$^$9$+!#(B

(2010/10/27 23:40), Nobuyoshi N. wrote:

[email protected]$G$9!#(B

At Wed, 27 Oct 2010 20:48:08 +0900,
Usaku NAKAMURA wrote in [ruby-dev:42464]:

[email protected]$H(Biconv$B$r;H$&I,[email protected]$,$[$H$s$I$J$$$H;W$&$N$G$9$,!"(B
$B$I$&$G$7$g$&$+(B?($BBe$o$j$K(BString#encode$B$r;H$&(B)

$B$5$C$/$j(Bext/iconv$B:o=|$7$^$9$+!#(B

$B$^[email protected]$=$N;~$8$c$J$$$G$7$g$&!#(B
2.0 $B$G$N>CLG$O4{DjO)@[email protected]$H$b;W$C$F$$$^$9$,!#(B

$B$3$s$K$A$O!"$J$+$`$i(B($B$&(B)$B$G$9!#(B

In message “[ruby-dev:42466] Re: [Ruby 1.9-Bug#3990][Assigned] tests of
rexml/rss reports many errors and failures without iconv”
on Oct.27,2010 23:40:38, [email protected] wrote:

[email protected]$H(Biconv$B$r;H$&I,[email protected]$,$[$H$s$I$J$$$H;W$&$N$G$9$,!"(B
$B$I$&$G$7$g$&$+(B?($BBe$o$j$K(BString#encode$B$r;H$&(B)

$B$5$C$/$j(Bext/iconv$B:o=|$7$^$9$+!#(B

iconv$BMW$i$J$$GI$N;d$G$O$"$j$^$9$,!"%W%i%C%H%U%)!<%`[email protected]$N(B
$B0];}[email protected]$+$i!"$$$-$J$j$N:o=|$K$O6/$/H?BP$7$^$9!#(B
1.9.3$B$^$G$O!V$b$&$9$0>C$9$h!W7Y9p$/$i$$$,E,@Z$G$O$J$$$G$7$g$&(B
$B$+!#(B

$B$"$H$^$"!"(Bext/iconv$B$,I8=`$GE:IU$5$l$k$Y$-$+$I$&$+$K$O6/$$5?G0(B
$B$rJz$$$F$O$$$^$9$,!“4:$($F$=$l$r;H$&>lLL$b$”$j$($k$H$O;W$C$F(B
$B$$$^$9!#(B

$B$=$l$G$O!#(B

iconv.so$B$,$J$$4D6-$G(Btest-all$B$r<B9T$9$k$H!"(Brexml$B$H(Brss$B$N%F%9%H$G(B
$B7k9=$J?t$N(BE$B$H(BF$B$,H/@8$7$^$9!#(B
$B$R$I$$%F%9%H$K$J$k$H(B require “iconv” $B$H$+$$$-$J$j=q$$$F$"$C$?$j(B
$B$H$+$7$^$9!#(B

$B<j85$G(Biconv.so$B$r>C$7$F;n$7$F$_$?$N$G$9$,!"(Brss$B$N%F%9%H$O<:GT(B
$B$7$^$;$s$G$7$?!#!J(Brexml$B$O<:GT$7$^$7$?!#!K(B

$B7k9=$J?t$N(BE$B$H(BF$B$N7k2L$r8+$;$F$b$i$($^$9$+!)(B

$B%A%1%C%H(B #3990 $B$,99?7$5$l$^$7$?!#(B (by Shota F.)

Shota F. (sora_h)$B$G$9!#(B

rexml$B$N%F%9%H$O$H$j$"$($:(Biconv$B$r2sHr$9$k$h$&$K$7$F$_$^$7$?$,$$$+$,$G$7$g$&$+!#(B

diff --git test/rexml/test_changing_encoding.rb
test/rexml/test_changing_encoding.rb
index f83247a…7bb465b 100644
— test/rexml/test_changing_encoding.rb
+++ test/rexml/test_changing_encoding.rb
@@ -1,15 +1,13 @@
#!/usr/bin/ruby -Ku

-- coding: utf-8 --

-require ‘kconv’
-require ‘iconv’
require ‘rexml/encoding’

class ChangingEncodings < Test::Unit::TestCase
def initialize a
@u = ‘$B%F%9%H(B $B$[$2(B $B$U$,(B $BH~$7$$(B’

  • @e = Kconv.toeuc(@u)
  • @e = @u.encode(‘euc-jp’)
    @f = Foo.new
    super
    end
    diff --git test/rexml/test_core.rb test/rexml/test_core.rb
    index 48a31ae…461f7f2 100644
    — test/rexml/test_core.rb
    +++ test/rexml/test_core.rb
    @@ -1123,7 +1123,6 @@ EOL
    end

def test_repeated_writes

  • require ‘iconv’
    a = IO.read(fixture_path(“iso8859-1.xml”))
    f = REXML::Formatters::Pretty.new

$B%A%1%C%H(B #3990 $B$,99?7$5$l$^$7$?!#(B (by Kouhei S.)

$B%9%F!<%?%9(B Assigned$B$+$i(BClosed$B$KJQ99(B
$B?JD=(B % 0$B$+$i(B100$B$KJQ99(B

This issue was solved with changeset r29646.
Usaku, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

rexml$B$N%F%9%H$O$H$j$"$($:(Biconv$B$r2sHr$9$k$h$&$K$7$F$_$^$7$?$,$$$+$,$G$7$g$&$+!#(B

$B%F%9%[email protected]$1$8$c$J$/$FK\BN$bD>$5$J$$$H$$$1$J$$$N$G!"[email protected][email protected](B
$B$HB-$j$J$$$H;W$$$^$9!#(B

[email protected]$G$9!#(B

(2010/10/30 10:33), Kouhei S. wrote:

iconv.so$B$,$J$$4D6-$G(Btest-all$B$r<B9T$9$k$H!"(Brexml$B$H(Brss$B$N%F%9%H$G(B
$B7k9=$J?t$N(BE$B$H(BF$B$,H/@8$7$^$9!#(B
$B$R$I$$%F%9%H$K$J$k$H(B require “iconv” $B$H$+$$$-$J$j=q$$$F$"$C$?$j(B
$B$H$+$7$^$9!#(B

$B<j85$G(Biconv.so$B$r>C$7$F;n$7$F$_$?$N$G$9$,!"(Brss$B$N%F%9%H$O<:GT(B
$B$7$^$;$s$G$7$?!#!J(Brexml$B$O<:GT$7$^$7$?!#!K(B

$B7k9=$J?t$N(BE$B$H(BF$B$N7k2L$r8+$;$F$b$i$($^$9$+!)(B

$B!!(Bmswin32 $B$G(B iconv.so $B!J$H$+!"(Bzlib $B$H$+(B openssl
$B$H$+!K$NL5$$4D6-$G$d$C$F(B
$B$_$^$7$?!#(Bskip $B$r=|$$$?7k2L$rAw$j$^$9!#(B

ruby 1.9.3dev (2010-10-30 trunk 29647) [i386-mswin32_100]

  1. Error:
    test_pos(ContribTester):
    Errno::ENOENT: No such file or directory - /tmp/tidal7916
    C:/ko1/src/ruby/clean-trunk/test/rexml/test_contrib.rb:524:in
    initialize' C:/ko1/src/ruby/clean-trunk/test/rexml/test_contrib.rb:524:inopen’
    C:/ko1/src/ruby/clean-trunk/test/rexml/test_contrib.rb:524:in
    `test_pos’

  2. Failure:
    test_utime(TestFileExhaustive)
    [C:/ko1/src/ruby/clean-trunk/test/ruby/test_file_
    exhaustive.rb:347]:
    <2000-01-01 00:00:01 +0000> expected but was
    <1999-12-31 23:00:01 +0000>.

  3. Error:
    test_install_check_dependencies_install_dir(TestGemInstaller):
    Errno::EACCES: Permission denied -
    (C:/Users/ko1/AppData/Local/Temp/test_rubygem
    s_7916/gemhome,
    C:/Users/ko1/AppData/Local/Temp/test_rubygems_7916/gemhome2)

C:/ko1/src/ruby/clean-trunk/test/rubygems/test_gem_installer.rb:598:in
test _install_check_dependencies_install_dir' C:/ko1/src/ruby/clean-trunk/test/runner.rb:19:in

  1. Failure:
    test_utime(TestPathname)
    [C:/ko1/src/ruby/clean-trunk/test/pathname/test_pathnam
    e.rb:928]:
    <2000-01-01 00:00:00 UTC> expected but was
    <1999-12-31 23:00:00 +0000>.

8143 tests, 1871492 assertions, 2 failures, 2 errors, 53 skips

Test run options: --seed 17133 --verbose
NMAKE : fatal error U1077: ‘.\ruby.exe’ : $B%j%?!<%s(B $B%3!<%I(B ‘0x4’
Stop.

$B!!(B1 $B$O!"2?$+JQ$($F$b$i$C$?$[$&$,$$$$$+$b!#(B

$B!!(B8$B!"(B41 $B$O!":#!"4D6-$,$,2F;[email protected]$+$i$+$J$!!)(B

$B!!(B25 $B$O!"$J$<(B Permission denied $B$+!#(B

$B<j85$G(Biconv.so$B$r>C$7$F;n$7$F$_$?$N$G$9$,!"(Brss$B$N%F%9%H$O<:GT(B
$B$7$^$;$s$G$7$?!#!J(Brexml$B$O<:GT$7$^$7$?!#!K(B

$B7k9=$J?t$N(BE$B$H(BF$B$N7k2L$r8+$;$F$b$i$($^$9$+!)(B

$B$(!"$=$s$JGO</$J!"$H;W$C$?$i!":#$N([email protected]$HH/@8$7$J$/$J$C$F$$(B
$B$^$9$M(B…
[email protected]$1$I(Br29646$B$N$*$+$2$8$c$J$$$N$+$7$i!#(B

$B$"!"$=$l$O!"$?$V$s$=$&$G$9!#(B
$BD>$7$?$D$b$j$J$N$G!#(B

$B$H$j$"$($:!"$=$&$$$&$o$1$J$N$G8=>u$GLdBj$O$J$$$h$&$J5$$,$7$^(B
$B$9!#(B
$BI,MW$J$iA0$N%j%S%8%g%s$^$G4,$-La$7$F3NG’$7$^$9$1$I!"MW$j$^$9(B?

$B$$$(!“8=>u$GLdBj$J$$$N$G$”$l$PI,MW$J$$$G$9!#(B

$B$3$s$K$A$O!"$J$+$`$i(B($B$&(B)$B$G$9!#(B

In message “[ruby-dev:42498] Re: [Ruby 1.9-Bug#3990][Assigned] tests of
rexml/rss reports many errors and failures without iconv”
on Oct.30,2010 18:33:34, [email protected] wrote:

iconv.so$B$,$J$$4D6-$G(Btest-all$B$r<B9T$9$k$H!"(Brexml$B$H(Brss$B$N%F%9%H$G(B
$B7k9=$J?t$N(BE$B$H(BF$B$,H/@8$7$^$9!#(B
$B$R$I$$%F%9%H$K$J$k$H(B require “iconv” $B$H$+$$$-$J$j=q$$$F$"$C$?$j(B
$B$H$+$7$^$9!#(B

$B<j85$G(Biconv.so$B$r>C$7$F;n$7$F$_$?$N$G$9$,!"(Brss$B$N%F%9%H$O<:GT(B
$B$7$^$;$s$G$7$?!#!J(Brexml$B$O<:GT$7$^$7$?!#!K(B

$B7k9=$J?t$N(BE$B$H(BF$B$N7k2L$r8+$;$F$b$i$($^$9$+!)(B

$B$(!"$=$s$JGO</$J!"$H;W$C$?$i!":#$N([email protected]$HH/@8$7$J$/$J$C$F$$(B
$B$^$9$M(B…
[email protected]$1$I(Br29646$B$N$*$+$2$8$c$J$$$N$+$7$i!#(B
$B$H$j$"$($:!"$=$&$$$&$o$1$J$N$G8=>u$GLdBj$O$J$$$h$&$J5$$,$7$^(B
$B$9!#(B
$BI,MW$J$iA0$N%j%S%8%g%s$^$G4,$-La$7$F3NG’$7$^$9$1$I!"MW$j$^$9(B?

$B$=$l$G$O!#(B

[email protected]@%$G$9!#(B

(2010/10/30 21:17), Kouhei S. wrote:

  lib/rexml/output.rb, lib/rexml/parseexception.rb,
  lib/rexml/parsers/baseparser.rb, lib/rexml/source.rb,
  lib/rexml/xmldecl.rb: use Ruby's native Encoding object.

* test/rexml/, test/rss/: follow the above encoding chagnes.

* NEWS: add REXML's incompatible change about encoding.

$B$3$NJQ99$G$O!"(BRuby M17N $B$N(B encoding system
$B$r;H$&$h$&$K$7$F$$$^$9$,!"(B
$BF3F~$7$?Hs8_49JQ99$K$OH?BP$G$9!#(B

[email protected]$H$7$F!"(BREXML $B$O(B Ruby
$BE*$KHs?d>)$H$$$&07$$$K$J$j$D$D$"$k$H$$$&$N$O(B
$B9g0U$,$H$l$F$$$k$H;W$o$l$k$H$3$m!"$3$N>u672<$GHs8_49JQ99$r$9$k$N$O(B
[email protected]$H;W$$$^$9!#(B

$B$^$?!":#2s$N(B REXML::Document#encoding, REXML::XMLdecl#encoding,
REXML::Output#encoding and REXML::Source#encoding $B$O!"(B
$B%I%-%e%a%s%H$,<+>N$7$F$$$k%(%s%3!<%G%#%s%0$H!"(BRuby
$B$,2r<a$7;H$C$F$$$k(B
$B%(%s%3!<%G%#%s%0$OJ,N%$9$k$Y$-$G$7$g$&!#(B
$BD>6a$G$O(B UTF-16BE/UTF-16LE $B$O(B BOM $B$J$7$r0UL#$9$k$N$G!"(B
BOM $BIU$-$N(B UTF-16 $B$,M_$7$$$H$-$K:$$j$^$9!#(B
$B!J$J$*!"(BUTF-16 $B$O(B ASCII incompatible
$B$J$N$G?’!9%P%0$C$F$k5$$,$9$k!K(B

$B$H$$$&$o$1$G!"(Bencoding $B%a%=%C%I$O0JA0$N$^$^$K$7$F!"(BEncoding
$B%*%V%8%’%/%H$r(B
$BJV$9%a%=%C%[email protected]_$7$?J}$,$h$$$N$G$O$J$$$+$H;W$$$^$9!#(B

(2010/11/02 21:50), Kouhei S. wrote:

$B$=$N0U8+$O$o$+$i$J$/$b$o$+$i$J$/$b$J$$$G$9!#(B
$B;d$bLB$$$^$7$?!#(B

[email protected]!"H?BP$NM}M3$H$7$F0J2<$O<e$$$H46$8$^$9!#(B
$BHs?d>)$H$+$$$D$J$/$J$k$H$+$,3NDj$7$F$$$k$/$i$$I,[email protected]$H46$8$^$9!#(B

$B$o$6$o$6Hs8_49$rF~$l$k$h$&$J%i%$%V%i%j$G$O$J$$$H$$$&<q;]$G$9!#(B
$BI,[email protected]$N$"$kJ*$J$i$P$7$g$&$,$J$$$G$9$,!"$3$l$O0c$&$H;W$$$^$9!#(B

[email protected]$H$7$F!"(BREXML $B$O(B Ruby
$BE*$KHs?d>)$H$$$&07$$$K$J$j$D$D$"$k$H$$$&$N$O(B

$B9g0U$,$H$l$F$$$k$H;W$o$l$k$H$3$m!"$3$N>u672<$GHs8_49JQ99$r$9$k$N$O(B
[email protected]$H;W$$$^$9!#(B

$B8D?ME*$K$OI8=`E:IU$5$l$F$$$k(BXML$B%Q!<%5$O(BRuby$B$N$_$G=q$+$l$?$b(B
$B$N$NJ}$,$$$$$H;W$C$F$$$^$9!#(BNokogiri$B$H$+$O(Bgem$B$G$$$$$H;W$C$F(B
$B$$$^$9!#(B

Nokogiri $B$rE:[email protected][email protected]$C$F$$$^$;$s!#(B

$B$^$?!":#2s$N(B REXML::Document#encoding, REXML::XMLdecl#encoding,
REXML::Output#encoding and REXML::Source#encoding $B$O!"(B
$B%I%-%e%a%s%H$,<+>N$7$F$$$k%(%s%3!<%G%#%s%0$H!"(BRuby $B$,2r<a$7;H$C$F$$$k(B
$B%(%s%3!<%G%#%s%0$OJ,N%$9$k$Y$-$G$7$g$&!#(B

$B0U?^$7$F$$$k$3$H$rM}2r$G$-$F$$$k<+?.$,$J$$$N$G$9$,!"%(%s%3!<(B
$B%G%#%s%0$rI=$9$N$K(BEncoding$B%*%V%8%’%/%H$r;H$&$N$O$h$/$J$$!"$H(B
$B$$$&$3$H$G$9$+!)(B

$B$O$$!#(B
$B$=$l$>$l$N%(%s%3!<%G%#%s%0$N<B:]>e$N<MDxHO0O$OJ8L.$K$h$C$FBe$o$j$^$9!#(B
$B$=$7$F!"(BHTTP $B$d(B HTML$B!"(BXML $B$J$I$N%(%s%3!<%G%#%s%0$H!"(BRuby
M17N $B$N(B
$B%(%s%3!<%G%#%s%0$O0lIt<MDxHO0O$,0[$J$j$^$9!#(B

$BD>6a$G$O(B UTF-16BE/UTF-16LE $B$O(B BOM $B$J$7$r0UL#$9$k$N$G!"(B
BOM $BIU$-$N(B UTF-16 $B$,M_$7$$$H$-$K:$$j$^$9!#(B
$B!J$J$*!"(BUTF-16 $B$O(B ASCII incompatible $B$J$N$G?’!9%P%0$C$F$k5$$,$9$k!K(B

$B$b$H$b$H(BREXML$B$O=PNO;~$K(BBOM$B$r$D$1$J$$$N$G$9$,!"(BBOM$BIU$-$N(B
UTF-16$B$,I,MW$K$J$k$N$O$I$&$$$&>lLL$rA[Dj$7$F$$$^$9$+!)(B

BOM $B$r$D$1$J$$$N$O(B UTF-8 $B$NOC$G$O$"$j$^$;$s$+!#(B
$B$?$H$($P!"(B1.9.2 $B$^$G$O0J2<$G(B BOM $BIU$-(B big endian $B$J(B
UTF-16 $B$G=PNO$7$^$9$M!#(B

require ‘rexml/document’
doc = REXML::Document.new
doc << REXML::XMLDecl.new(‘1.0’, ‘UTF-16’)
doc.write(s="")
=> “\xFE\xFF\x00<\x00?\x00x\x00m\x00l\xFE\xFF\x00
\x00v\x00e\x00r\x00s\x00i\x00o\x00n\x00=\x00’\x00”

$B$3$l$N7k2L$O!"8=:_0J2<$NDL$j$K$J$C$F$7$^$C$F$$$^$9!#(B
=> “<?xml version='1.0' encoding='UTF-16'?>”

$B$3$l$K$h$C$F!">/$J$/$H$b(B XMLDecl#encoding $B$NLa$jCM$N0UL#$O!"(B
XML [email protected]@$N(B encoding [email protected]$GMQ$$$i$l$kCM$G$"$C$F!“FbMF$N(B Ruby
$B$NJ8L.$K$$1$k(B
encoding $B$H$O0[$J$kJ
$G$”$k$H$$$($k$N$G$O$J$$$G$7$g$&$+!#(B
$B$=$b$=$b!"(BUTF-16 $B$N>l9g(B UTF-8 $B$KJQ49$7$F07$&$7!#(B

$B$3$3$b0U?^$rM}2r$7$F$$$k<+?.$,$J$$$N$G$9$,!"(BRuby$B$N(BEncoding$B$O(B
$B$^[email protected](BIconv$B$NBe$o$j$K$O;H$($J$$$H$$$&$3$H$G$9$+!)(B

$B$^$:!“J8;zNs$N%(%s%3!<%G%#%s%0$r07$&ItJ,$H!“JQ49$r;J$k(B transcode
$B$r(B
$BJ,$1$F9M$($kI,MW$,$”$j$^$9!#(B
$B$G!”(Biconv $B$NBe$o$j$K$J$kJ*$O(B transcode $B$G$"$C$F(B Encoding
$B$OJL$NOC$G$9!#(B

$B$H$$$&$o$1$G!"(Bencoding $B%a%=%C%I$O0JA0$N$^$^$K$7$F!"(BEncoding
$B%*%V%8%’%/%H$r(B

$BJV$9%a%=%C%[email protected]_$7$?J}$,$h$$$N$G$O$J$$$+$H;W$$$^$9!#(B

encoding$B$h$j$b(BEncoding$B%*%V%8%’%/%H$rJV$9$N$KE,@Z$JL>A0$r;W$$(B
$B$D$1$J$$$N$G!"$=$&$$$&(BAPI$B$K$O$7$J$$J}$,$h$$$H;W$C$F$$$^$9!#(B

Encoding $B%*%V%8%’%/%H%P!<%8%g%s$NL>A0$r$I$&$9$k$+!"$H$$$&$N$O!"(B
$B$=$l$O$=$l$GFq$7$$$N$G$9$,!">e=R$NM}M3$+$i$=$&$;$6$k$r$($J$$$H;W$$$^$9!#(B
$B;d0F$G$O(B string $B$N(B encoding $B$J$N$G(B str_encoding $B$+$J$!!#(B

$B?\F#$G$9!#(B

In [email protected]
“[ruby-dev:42510] Re: [Ruby 1.9-Bug#3990][Closed] tests of rexml/rss
reports many errors and failures without iconv” on Tue, 2 Nov 2010
03:15:40 +0900,
“NARUSE, Yui” [email protected] wrote:

$B$3$NJQ99$G$O!"(BRuby M17N $B$N(B encoding system
$B$r;H$&$h$&$K$7$F$$$^$9$,!"(B
$BF3F~$7$?Hs8_49JQ99$K$OH?BP$G$9!#(B

$B$=$N0U8+$O$o$+$i$J$/$b$o$+$i$J$/$b$J$$$G$9!#(B
$B;d$bLB$$$^$7$?!#(B

[email protected]!"H?BP$NM}M3$H$7$F0J2<$O<e$$$H46$8$^$9!#(B
$BHs?d>)$H$+$$$D$J$/$J$k$H$+$,3NDj$7$F$$$k$/$i$$I,[email protected]$H46$8$^(B
$B$9!#(B

[email protected]$H$7$F!"(BREXML $B$O(B Ruby
$BE*$KHs?d>)$H$$$&07$$$K$J$j$D$D$"$k$H$$$&$N$O(B
$B9g0U$,$H$l$F$$$k$H;W$o$l$k$H$3$m!"$3$N>u672<$GHs8_49JQ99$r$9$k$N$O(B
[email protected]$H;W$$$^$9!#(B

$B8D?ME*$K$OI8=`E:IU$5$l$F$$$k(BXML$B%Q!<%5$O(BRuby$B$N$_$G=q$+$l$?$b(B
$B$N$NJ}$,$$$$$H;W$C$F$$$^$9!#(BNokogiri$B$H$+$O(Bgem$B$G$$$$$H;W$C$F(B
$B$$$^$9!#(B

$B$^$?!":#2s$N(B REXML::Document#encoding, REXML::XMLdecl#encoding,
REXML::Output#encoding and REXML::Source#encoding $B$O!"(B
$B%I%-%e%a%s%H$,<+>N$7$F$$$k%(%s%3!<%G%#%s%0$H!"(BRuby $B$,2r<a$7;H$C$F$$$k(B
$B%(%s%3!<%G%#%s%0$OJ,N%$9$k$Y$-$G$7$g$&!#(B

$B0U?^$7$F$$$k$3$H$rM}2r$G$-$F$$$k<+?.$,$J$$$N$G$9$,!"%(%s%3!<(B
$B%G%#%s%0$rI=$9$N$K(BEncoding$B%*%V%8%’%/%H$r;H$&$N$O$h$/$J$$!"$H(B
$B$$$&$3$H$G$9$+!)(B

$BD>6a$G$O(B UTF-16BE/UTF-16LE $B$O(B BOM $B$J$7$r0UL#$9$k$N$G!"(B
BOM $BIU$-$N(B UTF-16 $B$,M_$7$$$H$-$K:$$j$^$9!#(B
$B!J$J$*!"(BUTF-16 $B$O(B ASCII incompatible $B$J$N$G?’!9%P%0$C$F$k5$$,$9$k!K(B

$B$b$H$b$H(BREXML$B$O=PNO;~$K(BBOM$B$r$D$1$J$$$N$G$9$,!"(BBOM$BIU$-$N(B
UTF-16$B$,I,MW$K$J$k$N$O$I$&$$$&>lLL$rA[Dj$7$F$$$^$9$+!)(B

$B$3$3$b0U?^$rM}2r$7$F$$$k<+?.$,$J$$$N$G$9$,!"(BRuby$B$N(BEncoding$B$O(B
$B$^[email protected](BIconv$B$NBe$o$j$K$O;H$($J$$$H$$$&$3$H$G$9$+!)(B

$B$H$$$&$o$1$G!"(Bencoding $B%a%=%C%I$O0JA0$N$^$^$K$7$F!"(BEncoding
$B%*%V%8%’%/%H$r(B
$BJV$9%a%=%C%[email protected]_$7$?J}$,$h$$$N$G$O$J$$$+$H;W$$$^$9!#(B

encoding$B$h$j$b(BEncoding$B%*%V%8%’%/%H$rJV$9$N$KE,@Z$JL>A0$r;W$$(B
$B$D$1$J$$$N$G!"$=$&$$$&(BAPI$B$K$O$7$J$$J}$,$h$$$H;W$C$F$$$^$9!#(B

$B?\F#$G$9!#(B

In [email protected]
“[ruby-dev:42515] Re: [Ruby 1.9-Bug#3990][Closed] tests of rexml/rss
reports many errors and failures without iconv” on Tue, 2 Nov 2010
22:34:53 +0900,
“NARUSE, Yui” [email protected] wrote:

$B$3$NJQ99$G$O!"(BRuby M17N $B$N(B encoding system
$B$r;H$&$h$&$K$7$F$$$^$9$,!"(B

$BF3F~$7$?Hs8_49JQ99$K$OH?BP$G$9!#(B

$B$=$N0U8+$O$o$+$i$J$/$b$o$+$i$J$/$b$J$$$G$9!#(B
$B;d$bLB$$$^$7$?!#(B

[email protected]!"H?BP$NM}M3$H$7$F0J2<$O<e$$$H46$8$^$9!#(B
$BHs?d>)$H$+$$$D$J$/$J$k$H$+$,3NDj$7$F$$$k$/$i$$I,[email protected]$H46$8$^$9!#(B

$B$o$6$o$6Hs8_49$rF~$l$k$h$&$J%i%$%V%i%j$G$O$J$$$H$$$&<q;]$G$9!#(B

$B3NDj$7$F$$$J$$8=CJ3,$G$O$=$N$h$&$JBP>]$G$O$J$$$H$$$&$3$H$r<g(B
$BD%$7$F$$$^$9!#(B

$BI,[email protected]$N$"$kJ*$J$i$P$7$g$&$,$J$$$G$9$,!"$3$l$O0c$&$H;W$$$^$9!#(B

Ruby 1.9$B$G$O(BEncoding$B$^$o$j$N5!G=$HE}9g$5$l$k$N$OI,[email protected](B
$B$H9M$($F$$$^$9!#(B

[email protected]$H$7$F!"(BREXML $B$O(B Ruby
$BE*$KHs?d>)$H$$$&07$$$K$J$j$D$D$"$k$H$$$&$N$O(B

$B9g0U$,$H$l$F$$$k$H;W$o$l$k$H$3$m!"$3$N>u672<$GHs8_49JQ99$r$9$k$N$O(B
[email protected]$H;W$$$^$9!#(B

$B8D?ME*$K$OI8=`E:IU$5$l$F$$$k(BXML$B%Q!<%5$O(BRuby$B$N$_$G=q$+$l$?$b(B
$B$N$NJ}$,$$$$$H;W$C$F$$$^$9!#(BNokogiri$B$H$+$O(Bgem$B$G$$$$$H;W$C$F(B
$B$$$^$9!#(B

Nokogiri $B$rE:[email protected][email protected]$C$F$$$^$;$s!#(B

$B9g0U$,$H$l$F$$$k$o$1$G$O$J$$$3$H!J>/$J$/$H$bH?BP0U8+$,$"$k$H(B
$B$$$&$3$H!K<gD%$7$F$$$^$9!#(B

$B0U?^$7$F$$$k$3$H$rM}2r$G$-$F$$$k<+?.$,$J$$$N$G$9$,!"%(%s%3!<(B
$B%G%#%s%0$rI=$9$N$K(BEncoding$B%*%V%8%’%/%H$r;H$&$N$O$h$/$J$$!"$H(B
$B$$$&$3$H$G$9$+!)(B

$B$O$$!#(B
$B$=$l$>$l$N%(%s%3!<%G%#%s%0$N<B:]>e$N<MDxHO0O$OJ8L.$K$h$C$FBe$o$j$^$9!#(B
$B$=$7$F!"(BHTTP $B$d(B HTML$B!"(BXML $B$J$I$N%(%s%3!<%G%#%s%0$H!"(BRuby M17N
$B$N(B
$B%(%s%3!<%G%#%s%0$O0lIt<MDxHO0O$,0[$J$j$^$9!#(B

$B:#$O([email protected]$19M$($F$$$^$9!#(B
$B6qBNE*$K$O$I$3$,0[$J$k$N$G$7$g$&$+!#(B

$B;d$NG’<1$O0J2<$NDL$j$G$9!#(B

XML$B$N%(%s%3!<%G%#%s%0$O(BIANA$B$KEPO?$5$l$F$$$k(Bchaset$BL>$r%Y!<%9(B
$B$K$7$F$$$k!#(Bx-$B$O$8$^$j$N$b$N$J$I$b;H$($^$k$,!"(BREXML$B$G$O(B
$B%5%]!<%HBP>]30!#(B

  • Ruby$B$N(BEncoding$B$b(BIANA$B$r%Y!<%9$K$7$F$$$k!#(B

$B$J$N$G!"(BREXML$B$G;H$&HO0O$G$O==J,%+%P!<$7$F$$$k$HG’<1$7$F$$$^(B
$B$9!#(B

require ‘rexml/document’
doc = REXML::Document.new
doc << REXML::XMLDecl.new(‘1.0’, ‘UTF-16’)
doc.write(s="")
=> “\xFE\xFF\x00<\x00?\x00x\x00m\x00l\xFE\xFF\x00
\x00v\x00e\x00r\x00s\x00i\x00o\x00n\x00=\x00’\x00”

$B$?$7$+$K$=$&$G$9$M!#!J(Bbig endian$B$G$O$J$/(Blittle
endian$B$G$9$,!#!K(B
$B<:Ni$7$^$7$?!#(B

[email protected]!"$3$l$O(Biconv$B$rMxMQ$7$F$$$k>l9g$G(Biconv$B$,$J$$>l9g$O(BBOM$B$J(B
$B$7$K$J$C$F$$$?$O$:$G$9!#(B

$B:#$N$^$^$G$b(BBOM$B$r$D$1$k$/$i$$4JC1$J$N$G!“I,MW$G$”$l$P$D$1$F(B

$B$7$^$C$F$b$$$$$H$O;W$C$F$$$^$9!#(B

$B$3$l$N7k2L$O!"8=:_0J2<$NDL$j$K$J$C$F$7$^$C$F$$$^$9!#(B
=> “<?xml version='1.0' encoding='UTF-16'?>”

$B$3$N$h$&$KI=<($5$l$k$N$OE,@Z$K(Bencoding$B$,@_Dj$9$k$h$&$K$J$C$?(B
[email protected]$H;W$C$F$$$^$9!#([email protected]$H$A$c$s$H(BUTF-16BE$B$,@_Dj$5$l$F$$(B
$B$F!J$J$N$G(B\xXX$B$K$J$i$J$$$GI=<($5$l$k!K!"0JA0$O!J(BUTF-16$B$J$N(B
$B$K!K(BUTF-8$B$,@_Dj$5$l$F$$$?$H;W$$$^$9!#(B

$B$3$l$K$h$C$F!">/$J$/$H$b(B XMLDecl#encoding $B$NLa$jCM$N0UL#$O!"(B
XML [email protected]@$N(B encoding [email protected]$GMQ$$$i$l$kCM$G$"$C$F!“FbMF$N(B Ruby
$B$NJ8L.$K$$1$k(B
encoding $B$H$O0[$J$kJ
$G$”$k$H$$$($k$N$G$O$J$$$G$7$g$&$+!#(B

$B$9$_$^$;$s!"!VFbMF$N(B Ruby $B$NJ8L.$K$*$1$k(B
encoding$B!W$,2?$r;X$7(B
$B$F$$$k$N$+$,J,$+$j$^$;$s$G$7$?!#%F%-%9%H$N(Bencoding$B$H$+!"$=$&(B
$B$$$&0UL#$G$9$+!)$=$&[email protected]$H$7$F!"0[$J$k>l9g$O$I$&$7$?J}$,$h$$$H(B
$B$$$&$3$H$G$7$g$&$+!#(B

$B$A$J$_$K!"!V(BXMLDecl#encoding $B$NLa$jCM$N0UL#$O!"!W(BXML$B$H$7$FJ8(B
$B;zNs2=$7$?$H$-$K;H$o$l$k(Bencoding$B$G$b$"$j$^$9!#$^$H$a$k$H!":#(B
$B$O$3$&$J$C$F$$$k$H;W$C$F$$$^$9!#(B

  • REXML$B$N%*%V%8%’%/%H$r:n$k$H$-$N(Bencoding$B$O([email protected]@$G;XDj(B
  • REXML$B$N%*%V%8%’%/%H$rA`:n$9$k$H$-$NF~=PNO$O(BUTF-8
  • REXML$B$N%*%V%8%’%/%H$r(BXML$B$H$7$F=PNO$9$k;~$O(BXMLDecl#encoding

$B$=$b$=$b!"(BUTF-16 $B$N>l9g(B UTF-8 $B$KJQ49$7$F07$&$7!#(B

UTF-16$B0J30$N>l9g$G$b(BREXML$BFbIt$G$O>o$K(BUTF-8$B$G07$C$F$$$^$9!#(B

$B$3$3$b0U?^$rM}2r$7$F$$$k<+?.$,$J$$$N$G$9$,!"(BRuby$B$N(BEncoding$B$O(B
$B$^[email protected](BIconv$B$NBe$o$j$K$O;H$($J$$$H$$$&$3$H$G$9$+!)(B

$B$^$:!“J8;zNs$N%(%s%3!<%G%#%s%0$r07$&ItJ,$H!“JQ49$r;J$k(B transcode $B$r(B
$BJ,$1$F9M$($kI,MW$,$”$j$^$9!#(B
$B$G!”(Biconv $B$NBe$o$j$K$J$kJ*$O(B transcode $B$G$"$C$F(B Encoding
$B$OJL$NOC$G$9!#(B

$B$(!<$H!"$b$H$b$H(Biconv$B$NBe$o$j$K(BEncoding$B$r$H$$$&OC$+$i;O$^$C$F(B
$B$$$?$N$G(BEncoding$B$r;H$C$F$$$?$N$G$9$,!";H$$J,$1$?J}$,$h$$$N$G(B
$B$7$g$&$+!)(B

$B;H$$J,$1$?$H$7$F!"(Btranscode$B$,(Biconv$B$NBeBX$H$7$F;H$&$K$O$^[email protected](B
$B$$$H$$$&$3$H$G$"$l$P:#2s$NJQ99$O;~4|>[email protected]$C$?5$$,$7$^$9!#(B

$B$H$$$&$o$1$G!"(Bencoding $B%a%=%C%I$O0JA0$N$^$^$K$7$F!"(BEncoding
$B%*%V%8%’%/%H$r(B

$BJV$9%a%=%C%[email protected]_$7$?J}$,$h$$$N$G$O$J$$$+$H;W$$$^$9!#(B

encoding$B$h$j$b(BEncoding$B%*%V%8%’%/%H$rJV$9$N$KE,@Z$JL>A0$r;W$$(B
$B$D$1$J$$$N$G!"$=$&$$$&(BAPI$B$K$O$7$J$$J}$,$h$$$H;W$C$F$$$^$9!#(B

Encoding $B%*%V%8%’%/%H%P!<%8%g%s$NL>A0$r$I$&$9$k$+!"$H$$$&$N$O!"(B
$B$=$l$O$=$l$GFq$7$$$N$G$9$,!">e=R$NM}M3$+$i$=$&$;$6$k$r$($J$$$H;W$$$^$9!#(B
$B;d0F$G$O(B string $B$N(B encoding $B$J$N$G(B str_encoding $B$+$J$!!#(B

$B$&!<$s!">e=R$NM}M3$r<u$1F~$l$i$l$J$$$N$OJL$H$7$F$b!"$=$NL>A0(B
$B$O<u$1F~$l$i$l$J$$$G$9!#E,@Z$G$J$$>l=j$K$O$_=P$7$F$7$^$C$?46(B
$B$8$,$7$^$9!#(B

$B?\F#$G$9!#(B

$B8=;[email protected]$G$I$&$J$C$F$$$k$N$+$r3NG’$5$;$F$/[email protected]$5$$!#$=$l$K$h$C$F(B
$B?J$a$k=gHV$,JQ$o$C$F$/$k$H;W$C$F$$$^$9!#(B

$B0J2<$N$h$&$KG’<1$7$F$$$^$9$,$"$C$F$$$^$9$+!)(B

  1. [email protected]@%$5$s$O!V(BXMLDecl#enocding$B$J$I$OJ8;zNs$K$9$Y$-!W$H<g(B
    $BD%$7$F$$$k!#(B

1.$B$NM}M3$O([email protected]@MQ$N(Bencoding$B$H(Btranscode$BMQ$N(Bencoding$B$O(B
$B0[$J$k$+$i!#!J([email protected]@$O(BShift_JIS$B$G(Btranscode$BMQ$O(BCP932$B$H(B
$B$+!K(B

$BEv=i$N(B1.$B$NM}M3$O(B2.$B$G$O$J$/(BREXML$B$N([email protected]$r<:$o$;$k(B
$B$Y$-$G$O$J$$!"[email protected]$C$?$,!":#$O$=$NM}M3$O$J$/$J$j!"([email protected]$1(B
$B$K$J$C$F$$$k!#(B

In [email protected]
“[ruby-dev:42517] Re: [Ruby 1.9-Bug#3990][Closed] tests of rexml/rss
reports many errors and failures without iconv” on Wed, 3 Nov 2010
02:41:35 +0900,

[email protected]@%$G$9!#(B

$B$^$:!“[email protected]}$9$k$H!”(B
iconv:
ext/iconv $B$N$3$H!"J8;z%3!<%IJQ494o(B
glibc iconv $B$H$+(B GNU libiconv $B$H$+(B Citrus iconv $B$H$+$r8F$V(B

transcode:
transcode.c $B$H(B enc/trans/* $B$"$?$j$G<BAu$5$l!"(B
String#encode $B$H$+$G;H$o$l$kJ*(B

Encoding:
encoding.c $B$d(B enc/* $B$G<BAu$5$l!"(BEncoding
$B%/%i%9$H$7$F8=$l$?$j!"(B
String [email protected],I=8=$NN"$GJ8;z$rA`$k!#(B

(2010/11/02 23:38), Kouhei S. wrote:

$B$(!<$H!"$b$H$b$H(Biconv$B$NBe$o$j$K(BEncoding$B$r$H$$$&OC$+$i;O$^$C$F(B
$B$$$?$N$G(BEncoding$B$r;H$C$F$$$?$N$G$9$,!";H$$J,$1$?J}$,$h$$$N$G(B
$B$7$g$&$+!)(B

$B$H$$$&$o$1$G!"$3$3$O!V(Biconv $B$NBe$o$j$K(B transcode $B$r!W$G$9!#(B

$B;H$$J,$1$?$H$7$F!"(Btranscode$B$,(Biconv$B$NBeBX$H$7$F;H$&$K$O$^[email protected](B
$B$$$H$$$&$3$H$G$"$l$P:#2s$NJQ99$O;~4|>[email protected]$C$?5$$,$7$^$9!#(B

$B$3$l$OLdBj$J$$$H;W$$$^$9!#(B

$B$=$l$>$l$N%(%s%3!<%G%#%s%0$N<B:]>e$N<MDxHO0O$OJ8L.$K$h$C$FBe$o$j$^$9!#(B
$B$=$7$F!"(BHTTP $B$d(B HTML$B!"(BXML $B$J$I$N%(%s%3!<%G%#%s%0$H!"(BRuby M17N
$B$N(B

$B%(%s%3!<%G%#%s%0$O0lIt<MDxHO0O$,0[$J$j$^$9!#(B

$B:#$O([email protected]$19M$($F$$$^$9!#(B

$B8e=R$NDL$j!";v>p$OF1$8$G$9!#(B

$B6qBNE*$K$O$I$3$,0[$J$k$N$G$7$g$&$+!#(B

$B;d$NG’<1$O0J2<$NDL$j$G$9!#(B

  • XML$B$N%(%s%3!<%G%#%s%0$O(BIANA$B$KEPO?$5$l$F$$$k(Bchaset$BL>$r%Y!<%9(B
    $B$K$7$F$$$k!#(Bx-$B$O$8$^$j$N$b$N$J$I$b;H$($^$k$,!"(BREXML$B$G$O(B
    $B%5%]!<%HBP>]30!#(B

$B7zA0$O$=$&$G$9!#(B
$B$7$+$7!“8=<BLdBj$H$7$F$O(B ISO-8859-1 $B$H>N$7$D$DCf?H$O(B
Windows-1252 [email protected]$C$?$j$7$^$9!#(B
($BNc$($PL$;HMQ$G$”$k$O$:$N(B 0x80
$B$,$J$<$+;H$o$l$F$$$F!"$=$l$,%f!<%m5-9f$r4|BT$7$F$$$k(B)
$BF|[email protected]$($P1_5-9fLdBj$dGH%@%C%7%eLdBj$,$=$&$G$9$J!#(B

$BNr;KE7P0^[email protected]@$9$k$H!“Ev=i$N(B IANA Charsets
$B$O>pJs8r49MQId9f$NL>[email protected]$C$?$N$G!”(B
$B$=$NFbMF$K$D$$$F>:Y$J9g0U$O<h$i$l$F$$$^$;$s$G$7$?!#(B
charset
$B$H$$$&L>A0<+BN$,!“Id9f2=J8;z=89g$HJ8;zId9f2=J}<0$,J,2=$9$kA0$N$b$N(B
$B$G$”$k$3$H$rJ
[email protected]$($^$9!#(B
ISO-8859-1 $B$H(B Windows-1252 $B$N0c$$$d!"(BEUC-JP $B$,4^$`Jd=u4A;z$r(B
CP51932 $B$,4^$^$J$$(B
$B$3$H$b$3$NJU$N0l4D$G$7$g$&!#(B

$B$G!“8=<[email protected]$($P!”%$%s%?!<%M%C%H>e$K$*$$$F$[$H$s$I$N%G!<%?$O(B
Windows $B%Y!<%9$N(B
$B$b$N$H$J$C$F$$$^$9!#$^$?!"(BWindows
$B$N%G%U%!%/%H2=$K$D$i$l$F%$%s%?!<%M%C%H4XO"$N(B
$B%=%U%H%&%’%"$O(B Windows $B$NDj5A$K$"$o$;$k$h$&$K$J$j$D$D$"$j$^$9!#(B

$B$^$?!"(BUnicode
$BEP>l;~$K4{B8$NJ8;z%3!<%I$H$NJQ49I=$rE}0l$9$k$3$H$K<:GT$7$?;v$b(B
$BPN%$rA}Bg$5$;$F$$$^$9!#F|K$K$$$$F$OGH%@%C%7%eLdBj$,$=$l$G$9!#(B
$B$3$A$i$b!“JQ49I=$r(B Windows $B$K$”$o$;$k$3$H$K$J$j$D$D$"$j$^$9!#(B

$B0J>e$r$^$H$a$k$H!"!V(BIANA Charsets
$B$K$$1$kL>[email protected]<0$JDj5A!W$H!"(B
Windows $BM3Mh$N%G%U%!%/%H$OP
N%$7$F$$$k!"[email protected]$&$3$H$K$J$j$^$9!#(B

$B6qBNE*$K$I$N(B charset $B$,P*N%$7!"$=$N<BBV$O2?$J$N$+$O(B HTML5
$B$N?M!9$,$^$H$a$F$$$^$9!#(B
http://www.w3.org/TR/html5/parsing.html#character-encodings-0

$B$G!"(BREXML $B$N07$&(B XML
$B%G!<%?$,%$%s%?!<%M%C%H>e$N%G!<%[email protected]<0$JDj5A$+$iP*N%$7$F$$$k$+!"(B
$B$,[email protected]@$G$9$,!"(BREXML $B$N<g$?$kMQES$,(B RSS $B$G!"(BRSS
$B$N%G!<%?85$,(B blog $BEy$N(B Web $BG^BN$G!"(B
$B$=$l$i$,85!9$O(B Web
$B%V%i%&%67PM3$GF~NO$5$l$F$$$k$G$"$m$&;v$r9M$($k$H!"(B
$B>e=R$N>u67$HF1$8$J$s$8$c$J$$$G$9$+$M!#(B

  • Ruby$B$N(BEncoding$B$b(BIANA$B$r%Y!<%9$K$7$F$$$k!#(B

$B!V%Y!<%[email protected]$7$$$s$G$9$,!"(BRuby $B$G$O(B IANA
$B$N$"$kL>>N$N<BAu$K$O!"(B
[email protected]<0$JDj5A$r0lCW$5$;!"%G%U%!%/%H$KBP$7$F$O(B Windows
$BM3Mh$NL>A0$rM?$($F$$$^$9!#(B
$BNc$($P!"(BISO-8859-1 $B$H(B Windows-1252$B!"(BShift_JIS $B$H(B
Windows-31J$B!"(B
EUC-JP $B$H(B CP51932 $B$J$I$G$9!#(B

$B$J$N$G!“0lO”$NL>>N72$N6u4V$O0lCW$7$F$$$^$9$,!“0UL#$E$1$K$:$l$,$”$j$^$9!#(B

[email protected]$r?=$7$^$9$H!"$3$N0c$$$O>pJs8r49MQId9f$HFbIt=hM}[email protected]$C$?$j$7$^$9!#(B

$B$J$N$G!"(BREXML$B$G;H$&HO0O$G$O==J,%+%P!<$7$F$$$k$HG’<1$7$F$$$^$9!#(B

$B$H$$$&$o$1$G!"35$MHO0O$H$7$F$O%+%P!<$5$l$F$$$k$N$G$9$,!"0UL#[email protected]$,0c$&$o$1$G$9!#(B
$B%+%P!<$7$-$l$F$J$$Nc$r5s$2$k$H!"Nc$($P(B UTF-16 $B$H$+$G$9$+!#(B

$B$b$C$H$b!"$3$3$G=R$Y$?0c$$$r(B REXML
$B$G$^$H$b$K07$&$+$O$^$?JL$NOC$G$9!#(B

[email protected]!"$3$l$O(Biconv$B$rMxMQ$7$F$$$k>l9g$G(Biconv$B$,$J$$>l9g$O(BBOM$B$J(B
$B$7$K$J$C$F$$$?$O$:$G$9!#(B

$B:#$N$^$^$G$b(BBOM$B$r$D$1$k$/$i$$4JC1$J$N$G!“I,MW$G$”$l$P$D$1$F(B

$B$7$^$C$F$b$$$$$H$O;W$C$F$$$^$9!#(B

BOM $B$r$D$1$k>l9g$O(B encoding $B$O(B UTF-16 $B$G$J$1$l$P$$$1$^$;$s!#(B
$B0lJ}$G!"(BUTF-16BE $B$rL>>h$k$J$i$P$=$l$K(B BOM
$B$r$D$1$F$O$$$1$^$;$s!#(B

$B$3$l$N7k2L$O!"8=:_0J2<$NDL$j$K$J$C$F$7$^$C$F$$$^$9!#(B
=> “<?xml version='1.0' encoding='UTF-16'?>”

$B$3$N$h$&$KI=<($5$l$k$N$OE,@Z$K(Bencoding$B$,@_Dj$9$k$h$&$K$J$C$?(B
[email protected]$H;W$C$F$$$^$9!#([email protected]$H$A$c$s$H(BUTF-16BE$B$,@_Dj$5$l$F$$(B
$B$F!J$J$N$G(B\xXX$B$K$J$i$J$$$GI=<($5$l$k!K!"0JA0$O!J(BUTF-16$B$J$N(B
$B$K!K(BUTF-8$B$,@_Dj$5$l$F$$$?$H;W$$$^$9!#(B

$BI=<(7k2L$K4X$7$F$O3N$+$K$4;XE&$NDL$j$G$9!#(B
$B$3$l$G!"(Bencoding=‘UTF-16BE’
$B$J$i$P$3$N7k2LC1BN$OLdBj$"$j$^$;$s$M!#(B

$B$3$l$K$h$C$F!">/$J$/$H$b(B XMLDecl#encoding $B$NLa$jCM$N0UL#$O!"(B
XML [email protected]@$N(B encoding [email protected]$GMQ$$$i$l$kCM$G$"$C$F!"FbMF$N(B Ruby
$B$NJ8L.$K$*$1$k(B

encoding $B$H$O0[$J$kJ*$G$"$k$H$$$($k$N$G$O$J$$$G$7$g$&$+!#(B

$B$9$_$^$;$s!"!VFbMF$N(B Ruby $B$NJ8L.$K$*$1$k(B encoding$B!W$,2?$r;X$7(B
$B$F$$$k$N$+$,J,$+$j$^$;$s$G$7$?!#%F%-%9%H$N(Bencoding$B$H$+!"$=$&(B
$B$$$&0UL#$G$9$+!)(B

$B6qBNNc$G$9$HNc$($P!"(B
‘<xml version=“1.0” encoding=“Shift_JIS”?>’.encode(“Windows-31”)
$B$H$+!#$3$3$G$N!VFbMF$N(B Ruby $B$NJ8L.$K$*$1$k(B encoding$B!W$O(B
Windows-31J $B$G$9!#(B

$B$=$&[email protected]$H$7$F!"0[$J$k>l9g$O$I$&$7$?J}$,$h$$$H(B
$B$$$&$3$H$G$7$g$&$+!#(B

XMLDec#encoding $B$OJ8;zNs$K$7$F!"(BXML [email protected]@$KF~$C$F$$$k$b$N$r(B
$B$=$N$^$^;H$&$Y$-$G$9!#(B

$B$A$J$_$K!"!V(BXMLDecl#encoding $B$NLa$jCM$N0UL#$O!"!W(BXML$B$H$7$FJ8(B
$B;zNs2=$7$?$H$-$K;H$o$l$k(Bencoding$B$G$b$"$j$^$9!#$^$H$a$k$H!":#(B
$B$O$3$&$J$C$F$$$k$H;W$C$F$$$^$9!#(B

  • REXML$B$N%*%V%8%’%/%H$r:n$k$H$-$N(Bencoding$B$O([email protected]@$G;XDj(B
  • REXML$B$N%*%V%8%’%/%H$rA`:n$9$k$H$-$NF~=PNO$O(BUTF-8
  • REXML$B$N%*%V%8%’%/%H$r(BXML$B$H$7$F=PNO$9$k;~$O(BXMLDecl#encoding

$B!V(BXML$B$H$7$FJ8;zNs2=$7$?$H$-$K;H$o$l$k(Bencoding$B!W$,>e=R$N!"(B
$B!VFbMF$N(B Ruby $B$NJ8L.$K$$1$k(B encoding$B!W$G$9!#(B
$B$G!"$3$l$O(B XMLDecl#encoding
$B$H$OJ,N%$9$kI,MW$,$"$j$^$9!JD94|E
$K$O!K!#(B
$B$=$3$^$G$d$i$J$$>l9g$O(B XMLDecl#encoding $BB&$K(B
$B!V(BXML$B$H$7$FJ8;zNs2=$7$?$H$-$K;H$o$l$k(Bencoding$B!W$r$"$o$;$k$Y$-$G$9!#(B

[email protected]$$49$($k$H!"(B

  • $B>pJs8r49MQId9fB&$KFbIt=hM}MQId9f$r$"$o$;$k$Y$-(B
  • XML $B$N8x>N$7$F$$$k%(%s%3!<%G%#%s%0L>$K$"$o$;$k$Y$-(B
  • Ruby $B$N(B Encoding
    $B%*%V%8%’%/%H$G$J$/!"%(%s%3!<%G%#%s%0L>$rJ8;zNs$N$^$^;H$&$Y$-(B
    $B$J$I$H$J$j$^$9!#(B

$B$=$b$=$b!"(BUTF-16 $B$N>l9g(B UTF-8 $B$KJQ49$7$F07$&$7!#(B

UTF-16$B0J30$N>l9g$G$b(BREXML$BFbIt$G$O>o$K(BUTF-8$B$G07$C$F$$$^$9!#(B

$B6D$k$H$*$j$G$9!#(B

$B$&!<$s!">e=R$NM}M3$r<u$1F~$l$i$l$J$$$N$OJL$H$7$F$b!"$=$NL>A0(B
$B$O<u$1F~$l$i$l$J$$$G$9!#E,@Z$G$J$$>l=j$K$O$_=P$7$F$7$^$C$?46(B
$B$8$,$7$^$9!#(B

Encoding $B%%V%8%’%/%H%P!<%8%g%s$,I,MW$J$N$O!">e=R$N(B
REXML
$B%
%V%8%’%/%H$+$i(BXML$B%=!<%9J8;zNs$KJQ49$9$k:]$KMQ$$$k%(%s%3!<%G%#%s%0$r!"(B
XML [email protected]@$N(B encoding [email protected]$NCM$H$OJL$K;}$AB3$1$?$$>l9g$NOC$J$N$G!"(B
$BKAF,$K=R$Y$?(B IANA Charsets $B$NDj5A$H(B Ruby
$B$N3F%(%s%3!<%G%#%s%0$NDj5A$N0c$$$r(B
$BCV$$$F$*$/$N$G$"$l$PITMW$G$9$M!#(B
$B$^$?!"(BXML $B%=!<%9$KJQ49$9$k:]$KJL$KM?$($k$H$$$&J}K!$b$"$j$^$9!#(B

[email protected]@%$G$9!#(B

(2010/11/03 8:24), Kouhei S. wrote:

$B8=;[email protected]$G$I$&$J$C$F$$$k$N$+$r3NG’$5$;$F$/[email protected]$5$$!#$=$l$K$h$C$F(B
$B?J$a$k=gHV$,JQ$o$C$F$/$k$H;W$C$F$$$^$9!#(B

$B0J2<$N$h$&$KG’<1$7$F$$$^$9$,$"$C$F$$$^$9$+!)(B

  1. [email protected]@%$5$s$O!V(BXMLDecl#enocding$B$J$I$OJ8;zNs$K$9$Y$-!W$H<g(B
    $BD%$7$F$$$k!#(B

$B$O$$!#(B

  1. 1.$B$NM}M3$O([email protected]@MQ$N(Bencoding$B$H(Btranscode$BMQ$N(Bencoding$B$O(B
    $B0[$J$k$+$i!#!J([email protected]@$O(BShift_JIS$B$G(Btranscode$BMQ$O(BCP932$B$H(B
    $B$+!K(B

$B$O$$!#(B

  1. $BEv=i$N(B1.$B$NM}M3$O(B2.$B$G$O$J$/(BREXML$B$N([email protected]$r<:$o$;$k(B
    $B$Y$-$G$O$J$$!"[email protected]$C$?$,!":#$O$=$NM}M3$O$J$/$J$j!"([email protected]$1(B
    $B$K$J$C$F$$$k!#(B

$B$3$3$OB>$N?M$K$b$o$+$j$K$/$$$H;XE&$5$l$?$N$G$9$,(B
$BEv=i$+$i(B 2. $B$H(B API [email protected]$NN>J}$,M}M3$G$9!#(B

$B$J$<[email protected]$r5s$2$?$+$H$$$&$H!"(BXMLDecl#encoding $B$r!"(B
XML [email protected]@MQ$H(B transcode $BMQ$N$I$A$i$N0UL#$K$9$k$+$r9M$($k:]!"(B
[email protected]*$K$O(B XML [email protected]@[email protected]$HM}[email protected]$+$i$G$9!#(B

transcode $BMQ$G$O;XDj<+BN$r(B CP932 $B$H$+$KJQ$($J$$$H$$$1$J$$(B

$B$H$$$&$+(B iconv $B$N;~$G$b(B Shift_JIS

$B$r;H$&$HGH%@%C%7%e$H$+$G$O$^$k(B

$B$o$?$7$N;[email protected][email protected]@$7$?J}$,$h$$5$$,$9$k$N$G$9$k$H!"(B

a. $B0JA0$+$i(B REXML $B$NJQ49<~$j$OA0=R$NM}M3$+$iCOMk$,$"$C$?(B
b. $B:#2s(B iconv $B$+$i(B transcode $B$XJQ49%(%s%8%s$,JQ$o$C$?(B
c. $BJ;$;$F(B XMLDecl#encoding $BEy$NLa$jCM$,JQ$o$C$?"*Hs8_49(B

$B$G!"(Bb. $B$K$O;[email protected]$G$9(B
a. [email protected]$H$O;W$C$F$$$^$9$,!"$+$H$$$C$Fe:No$J2r7h:v$,$"$k$o$1$G$b(B
$B$J$$$N$G!“6/$$0U8+$O;}$C$F$$$^$;$s!#(B
$B!JJQ49$G;H$&%(%s%3!<%G%#%s%0$rEO$;$k$H$$$$$+$J$!!”$/$i$$!K(B
c.
$B$OHs8_49$H$$$&[email protected][email protected]$,$"$k0lJ}!":#[email protected]$rBG$A>C$9$[$I$N%a%j%C%H$,(B
$B$"$k$H$O;W$C$F$$$^$;$s!#(B
String#encode $B$N%(%s%3!<%G%#%s%0;XDj$N$?$a$N0z?t$K$O(B String
$B$bEO$;$^$9$7!"(B
$BEO$9D>A0$K(B Shift-JIS ($B%O%$%U%s$N$d$D(B) $B$N$h$&$J$b$N$G$b!"(B
string.encode(REXML.find_encoding(“Shift-JIS”)) $B$J$I$H$+$^$;$k$H$+!"(B
$BJ}K!$O(B $B$"[email protected]$m$&$N$G!#(B

$B?\F#$G$9!#(B

In [email protected]
“[ruby-dev:42519] Re: [Ruby 1.9-Bug#3990][Closed] tests of rexml/rss
reports many errors and failures without iconv” on Wed, 3 Nov 2010
17:49:16 +0900,
“NARUSE, Yui” [email protected] wrote:

1.$B$NM}M3$O([email protected]@MQ$N(Bencoding$B$H(Btranscode$BMQ$N(Bencoding$B$O(B

$BEv=i$+$i(B 2. $B$H(B API [email protected]$NN>J}$,M}M3$G$9!#(B
$B$J$s$H!"$=$&[email protected]$C$?$N$G$9$+!#(B

$B$J$<[email protected]$r5s$2$?$+$H$$$&$H!"(BXMLDecl#encoding $B$r!"(B
XML [email protected]@MQ$H(B transcode $BMQ$N$I$A$i$N0UL#$K$9$k$+$r9M$($k:]!"(B
[email protected]*$K$O(B XML [email protected]@[email protected]$HM}[email protected]$+$i$G$9!#(B

transcode $BMQ$G$O;XDj<+BN$r(B CP932 $B$H$+$KJQ$($J$$$H$$$1$J$$(B

$B$H$$$&$+(B iconv $B$N;~$G$b(B Shift_JIS $B$r;H$&$HGH%@%C%7%e$H$+$G$O$^$k(B

$B$G$O!"(B2.$B$r2r7h$9$kJ}K!!J([email protected]@MQ$H(Btranscode$BMQ$N(Bencoding$B$rJL(B
$B$K4IM}$9$kJ}K!!K$r$$$/$D$+9M$($F!"$=$NCf$G0lHV$h$5$=$&$J$b$N(B
$B$K$D$$$F$=$l$,BEEv$+$r$"$i$?$a$F9M$($k!"$H$$$&N.$l$G$$$$$G$9(B
$B$+!)(B

$B$"$H!“0l1~3NG’$7$?$$$N$G$9$,!”;d$,%a%s%F%J%s%9$9$k$3$H$K$J$C(B
$B$?$N$G!"(BREXML$B$NJQ99$K$D$$$F$O;d$NH=CG$,:GM%@h$G$$$$$s$G$9$h(B
$B$M!);d$NH=CG$,$h$/$J$5$=$&$J>l9g$O!";d$,G<[email protected]$G$-$k$h$&[email protected]@(B
$B$7$F$b$i$C$F!"$=$l$G;d$,G<[email protected]$7$?$iJQ99$9$k!"$H$$$&$3$H$G$$$$(B
$B$s$G$9$h$M!)(B

$B$o$?$7$N;[email protected][email protected]@$7$?J}$,$h$$5$$,$9$k$N$G$9$k$H!"(B

$B$"$j$,$H$&$4$6$$$^$9!#(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs