Encoding.default_internal $B$N$?$a$N%Q%C%A(B

[ruby-core:18774] に Michael Selig から Encoding::default_internal
の提案がありました。

http://redmine.ruby-lang.org/wiki/ruby/DevelopersMeeting20080922
ã«è¿½åŠ ã—ãŸã‚‰
Encoding::default_internal (Michael Selig, ruby-core:18774)
結果は
→ pending (今週中)
となりました。この件を勧めるためにパッチを作りました。
よかったら入れておきますが、田中さん、成瀬さんあたりが
きっともっといいものを作れるのでこちらのパッチを使わなくても
いいです。

テストは未だ初期段階ですが、とりあえず次のようにテストしました
(実行は -Eutf-8, -Eshift_jis, -Eeuc-jp, そして -E 無しで、
ãã‚Œãžã‚Œã®å ´åˆ default_internal の値を色々変更しました
(合わせて最後の行のファイル番語も変更しないといけません))

Encoding.default_internal = ‘utf-8’
# tested with ‘utf-8’, ‘shift_jis’, and ‘euc-jp’

s = “\u3042\u3044\u3046\u3048\u304A”
File.open(‘testout1.txt’, ‘w:shift_jis’) do |f| f.write s end
File.open(‘testout2.txt’, ‘w:euc-jp’) do |f| f.write s end
File.open(‘testout3.txt’, ‘w:utf-8’) do |f| f.write s end

File.open(‘testout1.txt’, ‘r:shift_jis’) do |f| s = f.read; p s.encoding
end
File.open(‘testout2.txt’, ‘r:euc-jp’) do |f| s = f.read; p s.encoding
end
File.open(‘testout3.txt’, ‘r:utf-8’) do |f| s = f.read; p s.encoding end
File.open(‘testout3.txt’, ‘r:ASCII-8BIT’) do |f| s = f.read; p
s.encoding end

for next line, change file number to pick up default_internal

File.open(‘testout3.txt’, ‘r’) do |f| s = f.read; p s.encoding end

是非とも宜しくお願いします。 Martin.

#-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-# http://www.sw.it.aoyama.ac.jp mailto:[email protected]

e$B@.@%$G$9!#e(B

Martin D. wrote:

[ruby-core:18774] e$B$Ke(B Michael Selig e$B$+$ie(B Encoding::default_internal
e$B$NDs0F$,$"$j$^$7$?!#e(B

e$B$^$D$b$H$5$s$KCk$4$mJ9$$$?$H$3$m!"$^$@;W0FCf$N$h$&$G$9!#e(B

e$B7k6Ie(B default_internal e$B$C$F$N$Oe(B multi-locale e$B$r;X8~$9$ke(B
Ruby e$B$+$i$9$k$H5U9T$9$kB8:_$J$N$G!“Fq$7$$$H$3$m$G$O$”$j$^$9!#e(B

In article 6.0.0.20.2.20080924195217.06173a20@localhost,
Martin D. [email protected] writes:

http://redmine.ruby-lang.org/wiki/ruby/DevelopersMeeting20080922
e$B$KDI2C$7$?$ie(B
Encoding::default_internal (Michael Selig, ruby-core:18774)
e$B7k2L$Oe(B
→ pending (e$B:#=5Cfe(B)
e$B$H$J$j$^$7$?!#$3$N7o$r4+$a$k$?$a$K%Q%C%A$r:n$j$^$7$?!#e(B

Encoding.default_internal = ‘utf-8’
# tested with ‘utf-8’, ‘shift_jis’, and ‘euc-jp’

e$BJQ992DG=$H$9$k$3$H$K$D$$$F$O!"%9%l%C%I%;!<%U$G$J$$$3$H$K2??Me(B
e$B$b7|G0$rI=L@$7$F$$$^$9$M!#;d$b4m$&$$$H;W$$$^$9!#e(B

e$B$^$?!“JQ49$9$k$N$K$O$=$l$O$=$l$G6lO+$,$”$k$s$8$c$J$$$G$7$g$&e(B
e$B$+!#e(B

e$B$?$H$($P!"e(BPython 3000 e$B$G$O!“e(Bargv
e$B$KJQ$J%P%$%HNs$,M?$($i$l$?e(B
e$B>l9g$K5/F0;~$K%(%i!<$K$J$k$H$$$&OC$,$”$j$^$7$?!#e(B
http://mail.python.org/pipermail/python-3000/2007-September/010445.html
(e$B8=:_$I$&$J$C$F$$$k$+$O3NG’$7$F$$$^$;$s!#e(B)

e$BJQ49$9$k$H$$$&$3$H$O<:GT$9$k2DG=@-$,M-$k$o$1$G!“<:GT$r$&$^$/e(B
e$B07$($k$+9M$($F$_$kI,MW$,$”$k$N$G$O$J$$$G$7$g$&$+!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:36517] Re: Encoding.default_internal
e$B$N$?$a$N%Q%C%Ae(B”
on Wed, 24 Sep 2008 21:23:48 +0900, “NARUSE, Yui”
[email protected] writes:

|Martin D. wrote:
|> [ruby-core:18774] e$B$Ke(B Michael Selig e$B$+$ie(B Encoding::default_internal
|> e$B$NDs0F$,$“$j$^$7$?!#e(B
|
|e$B$^$D$b$H$5$s$KCk$4$mJ9$$$?$H$3$m!”$^$@;W0FCf$N$h$&$G$9!#e(B
|
|e$B7k6Ie(B default_internal e$B$C$F$N$Oe(B multi-locale e$B$r;X8~$9$ke(B
|Ruby e$B$+$i$9$k$H5U9T$9$kB8:_$J$N$G!“Fq$7$$$H$3$m$G$O$”$j$^$9!#e(B

e$B:#F|0lF|9M$($F!"F3F~$9$k$3$H$K$7$^$7$?!#e(B

e$B0J2<$N$h$&$J;EMM$r9M$($F$$$^$9!#e(B

default_internale$B$Oe(BIOe$B$Ge(Binternale$B$r;XDj$7$J$+$C$?>l9g$N%(%s%3!<e(B
e$B%G%#%s%0$G$"$ke(B
*
e$B$3$l$,;XDj$5$l$F$$$k;~e(BIOe$B$+$i$NF~NO$Oe(B(e$B%P%$%J%j$G$J$$8B$je(B)e$B!"e(B
e$B$3$N%(%s%3!<%G%#%s%0$r;}$De(B(e$BI,MW$J$iJQ49$9$ke(B)e$B!#e(B

  • default_internale$B$be(B-Ee$B%*%W%7%g%s$G;XDj$9$k!#;XDj=q<0$Oe(B

    -E iso-2022-jp:utf-8

    e$B$N$h$&$K!Ve(B:e$B!W$G6h@Z$C$?$b$N$H$9$k!#e(Bdefault_externale$B$H$7$Fe(B
    localee$B$r;XDj$7$?$$;~$K$O!"6u$Ne(Bdefault_externale$B$r;XDj$9$k$?e(B
    e$B$a$Ke(B

    -E :utf-8

    e$B$N$h$&$K=q$/!#5U$Ke(Bdefault_internale$B$X$NJQ49$rM^@)$9$k$?$a$Ke(B
    e$B$O!"6u$Ne(Bdefault_internale$B$r;XDj$7$Fe(B

    -E iso-2022-jp:

    e$B$N$h$&$K=q$/!#5lMh$N!Ve(B-E euc-jpe$B!W$O!Ve(B-E
    euc-jp:e$B!W$HF1$80Ue(B
    e$BL#$K$J$k!#e(B

(e$B=EMWe(B)e$B$J$K$b;XDj$7$J$$>l9g$Ne(Bdefault_externale$B$Oe(Blocalee$B!#e(B
default_internale$B$O!Ve(BUTF-8e$B!W!#e(B
*
e$B?7@_$Ne(B-Le$B%*%W%7%g%s$r;XDj$9$k$He(Bdefault_externale$B$Oe(Blocalee$B!"e(B
default_internale$B$O6u$K$J$k!#e(B

  • (e$BL$Dje(B)Dire$B$J$I$,JV$9%Q%9L>$Oe(Bdefault_externale$B$+$ie(B
    default_internale$B$X$NJQ49$,9T$o$l$k!#$?$@$7!"JQ49%(%i!<$,H/e(B
    e$B@8$7$?>l9g!"J8;z$,2=$1$k$N$OHr$1$?$$e(B(e$B%P%$%J%j$GJV$9$+e(B)e$B!#e(B

e$BGX7Je(B

e$B$3$3?t=54V??7u$K9M$($F$-$^$7$?$,!“FbIt%3!<%I$Ke(BUnicodee$B$r;H$o$Je(B
e$B$$M}M3$O$+$J$j8:$C$F$$$k$H;W$$$^$9!#3F<oJQ49%F!<%V%k$O%i%&%se(B
e$B%I%H%j%C%W$9$k$h$&$K@7W$5$l$F$$$^$9$7!"3F<o%3%9%H$b3+H/Ev=ie(B
(8e$BG/0J>eA0e(B)e$B$O$H$b$+$/8=:
$G$OL5;k$G$-$k%l%Y%k$K$J$C$F$$$^$9!#e(B
e$B$=$3$G!“FbIt%3!<%Ie(BUnicode(UTF-8)e$B$r;Y1g$7$D$D!“I,MW$G$”$l$PL5e(B
e$BJQ49%F%-%9%H=hM}$d$h$j9-$$J8;z=89ge(B(e$B$N<B83e(B)e$B$b2DG=$G$”$k;EMM$re(B
e$BLO:w$7$^$7$?!#7k2L!”%G%U%)%k%H$G$O30It%(%s%3!<%G%#%s%0$r%m%1!<e(B
e$B%k$+$i<hF@!“FbIt%(%s%3!<%G%#%s%0$Oe(BUTF-8e$B$H$7$^$7$?!#$7$+$7!”%me(B
e$B%1!<%k$K=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$$!#$G$-$k$@$1Aa5^$Ke(B
1.9.1e$B$K<h$j9~$b$&$H;W$$$^$9!#5^$$$G9M$($?$b$N$J$N$G8+Mn$H$7e(B
e$B$,$"$k$+$b$7$l$^$;$s!#$=$N>l9g$O1sN8$J$/;XE&$7$F$/$@$5$$!#e(B

e$B$3$l$K$H$b$J$$!“e(BUTF-{16,32}e$BBP1~$Oe(Bence$B$+$i30$7$?J}$,$h$$$+$b$7e(B
e$B$l$J$$$H;W$&$h$&$K$J$j$^$7$?!#$3$l$i$Oe(BUTF-8e$B$H$OId9f2=J}<0$Ne(B
e$B0c$$$7$+$”$j$^$;$s!#$^$C$?$/%G!<%?%m%9$J$7$KJQ49$G$-$k0J>e!“e(B
e$BBP1~$9$k%a%j%C%H$OBg$-$/$J$/!”:.Mp$N%G%a%j%C%He(B(e$B$?$H$($Pe(BCSVe$B%ie(B
e$B%$%V%i%j$,e(BUTF-16e$BBP1~$K6lO+$7$?e(B)e$B$NJ}$,Bg$-$=$&$G$9!#e(B

                            e$BD>A0$G?=$7Lu$J$$e(B
                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

e$B1J0f!wCNG=!%6e9)Bg$G$9!%e(B

From: Yukihiro M. [email protected]
Subject: [ruby-dev:36523] Re: Encoding.default_internal
e$B$N$?$a$N%Q%C%Ae(B
Date: Thu, 25 Sep 2008 00:49:10 +0900
Message-ID: [email protected]

|Martin D. wrote:
|> [ruby-core:18774] e$B$Ke(B Michael Selig e$B$+$ie(B Encoding::default_internal
|> e$B$NDs0F$,$“$j$^$7$?!#e(B
|
|e$B$^$D$b$H$5$s$KCk$4$mJ9$$$?$H$3$m!”$^$@;W0FCf$N$h$&$G$9!#e(B
|
|e$B7k6Ie(B default_internal e$B$C$F$N$Oe(B multi-locale e$B$r;X8~$9$ke(B
|Ruby e$B$+$i$9$k$H5U9T$9$kB8:_$J$N$G!“Fq$7$$$H$3$m$G$O$”$j$^$9!#e(B

e$B:#F|0lF|9M$($F!"F3F~$9$k$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e(B default_internal e$B$G!$e(B
default_internal e$B$,6u$G$"$k$J$ie(B default_extenral e$B$Ge(B
e$BJV$9$h$&$K$9$k$H$$$&$N$,4pK$G$7$g$&$+!)e(B

e$B$b$A$m$s$3$l$i$NJQ99$OK\F|$Ne(Bfeature freezee$B$K$O4V$K9g$$$^$;$se(B
e$B$,!“HaLD$r$”$2$?$b$N$@$H8+$J$7$F$/$@$5$$!#$G$-$k$@$1Aa5^$Ke(B
1.9.1e$B$K<h$j9~$b$&$H;W$$$^$9!#5^$$$G9M$($?$b$N$J$N$G8+Mn$H$7e(B
e$B$,$"$k$+$b$7$l$^$;$s!#$=$N>l9g$O1sN8$J$/;XE&$7$F$/$@$5$$!#e(B

e$B3HD%%i%$%V%i%jB&$Oe(B core e$B$N;EMM$,3NDj$7$J$$$HF0$-$E$i$$$G$9!%e(B
e$B$G!$e(Bfeature freeze e$B$,6a$E$$$F$+$ie(B core
e$B$,?'!9$H$$$8$i$l$k$He(B
e$BBP1~$,A4$/4V$K9g$$$^$;$s!%e(B

e$B!V$9$Y$F$NJQ99$KB(:B$KBP1~$7B3$1$k!W$H$$$&$N$O!$e(B

e$B$5$9$,$K$4MF<O$r!%e(B(^_^)

e$B$b$72DG=$G$"$k$J$i!$%j%j!<%9%9%1%8%e!<%k$K$*$$$F!$e(B
core e$B$Ne(B feature freeze e$B$+$ie(B ext e$B$Ne(B feature freeze
e$B$^$G$Ke(B
e$B>/$74V$r6u$1$F$$$?$@$1$k$H=u$+$j$^$9!%e(B

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

In message “[ruby-dev:36523] Re: Encoding.default_internal
e$B$N$?$a$N%Q%C%Ae(B”
on Sep.25,2008 00:49:10, [email protected] wrote:
| e$B:#F|0lF|9M$($F!"F3F~$9$k$3$H$K$7$^$7$?!#e(B
|
| e$B0J2<$N$h$&$J;EMM$r9M$($F$$$^$9!#e(B

e$B$S$C$/$j6DE7$J46$8$G$9$,!"$7$P$i$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B(1.9.1 e$B$H$+e(B
1.9.2)e$B$G40@.$9$k8+9~$_$b$J$$$N$G!“D>@\e(BUTF-16e$B%F%-%9%H$r07$&$3e(B
e$B$H$Oe(B(e$BEvLLe(B)e$B%5%]!<%H$7$J$/$F$b$h$$$N$G$O$J$$$+!”$H$$$&0UL#$G$9!#e(B

e$B$`!"e(BUTF-{16,32} e$B$KBP$9$k8+DL$7$,$o$?$7$H<c430c$&$+$b!#e(B

e$B;W$&$K!“8=:_7|0F$N=t!9$NLdBj$K0lDL$j2r$O$”$C$F!"C<E*$K8@$($Pe(B
e$B!Ve(B7bit ASCII String e$B$re(B UTF-16
e$B$K$7$F$/$C$D$1$l$P$$$$$@$1!W$G$9!#e(B

e$BNc$($P!"e(BUTF-16LE e$B$Ne(B str="e$B$“e(B” e$B$KBP$7$Fe(B
“text=#{str}” e$B$r9T$C$?>l9g!“e(B
e$B4|BT$5$l$kF0:n$Oe(B UTF-16LE e$B$Je(B “text=e$B$“e(B”
e$B$K7h$^$C$F$$$^$9!#e(B
e$B$D$^$j!”;EMM>e$NG:$_$O$”$j$^$;$s!#e(B
e$B<BAu$be(B “text=”.encode(“UTF-16LE”)
e$B$9$k$@$1$G$9$N$G!“LdBj$”$j$^$;$s!#e(B
e$B=hM}B.EY$b$^$!Bg>fIW$G$7$g$&!#e(B

e$B@55,I=8=$b;EMM>e$NG:$_$OA4$/$"$j$^$;$s!#e(B
e$B<BAu$b!“e(BUS-ASCII or UTF-8 e$B$J$i$PN”$Ge(B UTF-16LE
e$B$K%3%s%Q%$%k$7$J$$9!“e(B
e$B$H$$$&J}K!$,$”$j$^$9!#e(B
e$B6qBNE
$K$Oe(B Regexp.new(/\u3042/.source.encode(“UTF-16LE”))
e$B$H4JC1$J$b$N$G$9!#e(B

e$B$D$^$j!"FC$KG:$`E@$OB?$/$J$/!“C1$K;~4V$,B-$j$J$$$@$1$G$9!#e(B
e$B$H$O$$$(!”:n6HNL$b@dK>E*$J$[$IB?$$$o$1$G$b$J$$$N$G!"e(B
e$BJ*9%$-$,0l?M8=$l$l$PJRIU$/NL$G$7$g$&!#e(B

|e$B$3$l$,$G$-$J$$$h$&$K$J$k$N$G$"$l$P!";d$K$H$C$F$OHs>o$K;DG0$Je(B
|e$B7hDj$H$$$&$3$H$K$J$j$^$9e(B orz

e$B8D?ME*$K$O!Ve(BUTF-16e$B"*e(BUTF-8e$B"e(BUTF-16e$B!W%b%G%k$G==J,$G$"$j!"$+$De(B
ASCIIe$B8_49LdBj$r2sHr$G$-$k$3$H$N4r$7$5$NJ}$,Bg$-$$$H;W$C$F$$$ke(B
e$B$N$G$9$,e(B(e$B@55,I=8=$H$+$bHf3SE
<+A3$K;H$($k$h$&$K$J$k$7e(B)e$B!"$$$d!“e(B
e$B$=$l$G$be(BUTF-16e$B$r$=$N$^$^JQ49$J$7$K07$($kJ}$,NI$$$N$@$H$$$&$3e(B
e$B$H$G$”$l$P!"$<$R;XE&$7$F$/$@$5$$!#e(B

e$B0J>e$N$h$&$K!"e(BUTF-{16,32} e$B$O%P%$%HNs$H$7$F$Oe(B ASCII
e$BHs8_49$G$b!"e(B
e$B%3!<%I%]%$%s%HNs$H$7$F$Oe(B ASCII e$B8_49$J$N$G!"e(B
e$B$=$3$^$GG:$_$,B?$$$o$1$G$O$J$$$N$G$9!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:36532] Re: Encoding.default_internal
e$B$N$?$a$N%Q%C%Ae(B”
on Thu, 25 Sep 2008 06:03:31 +0900, “U.Nakamura”
[email protected] writes:

|| e$B0J2<$N$h$&$J;EMM$r9M$($F$$$^$9!#e(B
|
|e$B$S$C$/$j6DE7$J46$8$G$9$,!"$7$P$i$/9M$($J$$$H$h$/$o$+$s$J$5$=e(B
|e$B$&$G$9!#e(B
|e$B<B<AE*$K!“e(BUTF-8e$B2=$XMxMQ<T$rF3$/$3$H$K$J$j$=$&$G$9$,!”$=$l$b0Ue(B
|e$B?^$N$&$A$@$H$$$&$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8e!"=PNO$9$k$He(BUTF-16LE
e$B$KJQ49$5$l$F=PNO$9$k$3$H$K$J$j$^$9!#e(B

|e$B$3$l$,$G$-$J$$$h$&$K$J$k$N$G$“$l$P!”;d$K$H$C$F$OHs>o$K;DG0$Je(B
|e$B7hDj$H$$$&$3$H$K$J$j$^$9e(B orz

e$B8D?ME*$K$O!Ve(BUTF-16e$B"*e(BUTF-8e$B"e(BUTF-16e$B!W%b%G%k$G==J,$G$“$j!”$+$De(B
ASCIIe$B8_49LdBj$r2sHr$G$-$k$3$H$N4r$7$5$NJ}$,Bg$-$$$H;W$C$F$$$ke(B
e$B$N$G$9$,e(B(e$B@55,I=8=$H$+$bHf3SE
<+A3$K;H$($k$h$&$K$J$k$7e(B)e$B!“$$$d!“e(B
e$B$=$l$G$be(BUTF-16e$B$r$=$N$^$^JQ49$J$7$K07$($kJ}$,NI$$$N$@$H$$$&$3e(B
e$B$H$G$”$l$P!”$<$R;XE&$7$F$/$@$5$$!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

e$B@.@%$G$9!#e(B

Yukihiro M. wrote:

|
|e$B7k6Ie(B default_internal e$B$C$F$N$Oe(B multi-locale e$B$r;X8~$9$ke(B
|Ruby e$B$+$i$9$k$H5U9T$9$kB8:_$J$N$G!“Fq$7$$$H$3$m$G$O$”$j$^$9!#e(B

e$B:#F|0lF|9M$($F!"F3F~$9$k$3$H$K$7$^$7$?!#e(B

e$B0J2<$N$h$&$J;EMM$r9M$($F$$$^$9!#e(B

  • default_internale$B$Oe(BIOe$B$Ge(Binternale$B$r;XDj$7$J$+$C$?>l9g$N%(%s%3!<e(B
    e$B%G%#%s%0$G$"$ke(B

internal e$B$r;XDj$7$J$+$C$?>l9g!"e(BIO#internal_encoding e$B$Oe(B nil
e$B$N$^$^$Ge(B
e$B$$$$$G$7$g$&$+!#e(B

  • e$B$3$l$,;XDj$5$l$F$$$k;~e(BIOe$B$+$i$NF~NO$Oe(B(e$B%P%$%J%j$G$J$$8B$je(B)e$B!"e(B
    e$B$3$N%(%s%3!<%G%#%s%0$r;}$De(B(e$BI,MW$J$iJQ49$9$ke(B)e$B!#e(B

  • (e$B=EMWe(B)e$B$J$K$b;XDj$7$J$$>l9g$Ne(Bdefault_externale$B$Oe(Blocalee$B!#e(B
    default_internale$B$O!Ve(BUTF-8e$B!W!#e(B

  • e$B?7@_$Ne(B-Le$B%*%W%7%g%s$r;XDj$9$k$He(Bdefault_externale$B$Oe(Blocalee$B!"e(B
    default_internale$B$O6u$K$J$k!#e(B

e$B$3$l$O$3$N$^$^$@$H$^$:$$$G$9!#e(B
e$B$9$Y$F$,e(B UTF-8 e$B$J$i$P8@$&$^$G$bLdBj$"$j$^$;$s!#e(B
e$B$7$+$7!"F~NO85!&=PNO@h!&%9%/%j%W%H$N%j%F%i%k$,A4$FNc$($Pe(B CP932
e$B$N>l9g!"e(B
Ruby 1.9 e$B$G$OF~NO$H%j%F%i%k$r7k9g$G$-$^$;$s!#e(B
e$B$3$l$,!"e(BPerl
e$BEy$N>l9g$O%j%F%i%k$bJQ49$7$F$7$^$&$N$GLdBj$J$$$N$G$9$,!"e(B
Ruby 1.9 e$B$G$Oe(B e$B%j%F%i%k$O$=$N$^$^$J$N$GIT0lCW$,H/@8$7$^$9!#e(B

oneliner
e$BEy$N4JC1$J%9%/%j%W%H$G%j%F%i%k$r$=$N$^$^G’<1$5$;$?$$>l9g$K!"e(B
-L e$B0l$D$H$O$$$(%*%W%7%g%s$,I,MW$H$$$&$N$OHQ;($G$O$J$$$G$7$g$&$+!#e(B

e$B$3$l$N0l$D$N2r7h:v$O%j%F%i%k$be(B default_internal
e$B$KJQ49$7$F$7$^$&$3$H$G$9!#e(B

e$B$b$&0l$D$Oe(B default_internal e$B$N=i4|CM$r6u$K$7!"e(B
Unicoder e$BMQ$N%*%W%7%g%s$r?7@_$9$k$3$H$G$9e(B (e$B9,$$e(B -U
e$B$,6u$$$F$$$^$9e(B)e$B!#e(B

e$B;W$&$K!“e(BRuby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$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:36534] Re: Encoding.default_internal
e$B$N$?$a$N%Q%C%Ae(B”
on Thu, 25 Sep 2008 06:31:27 +0900, “NARUSE, Yui”
[email protected] writes:

|> e$B0J2<$N$h$&$J;EMM$r9M$($F$$$^$9!#e(B
|>
|> * default_internale$B$Oe(BIOe$B$Ge(Binternale$B$r;XDj$7$J$+$C$?>l9g$N%(%s%3!<e(B
|> e$B%G%#%s%0$G$"$ke(B
|
|internal e$B$r;XDj$7$J$+$C$?>l9g!"e(BIO#internal_encoding e$B$Oe(B nil e$B$N$^$^$Ge(B
|e$B$$$$$G$7$g$&$+!#e(B

default_internale$B$,e(Bnile$B$N;~!"e(B

open(path, “r”)

e$B$Oe(B

open(path, “r:default_external”)

e$B$H2r<a$5$l$^$9!#e(Bnile$B$G$J$$;~!"e(B

open(path, “r:default_external:internal_encoding”)

e$B$K$J$j$^$9!#e(B

|> * e$B?7@$Ne(B-Le$B%%W%7%g%s$r;XDj$9$k$He(Bdefault_externale$B$Oe(Blocalee$B!“e(B
|> default_internale$B$O6u$K$J$k!#e(B
|
|e$B$3$l$O$3$N$^$^$@$H$^$:$$$G$9!#e(B
|e$B$9$Y$F$,e(B UTF-8 e$B$J$i$P8@$&$^$G$bLdBj$”$j$^$;$s!#e(B
|e$B$7$+$7!"F~NO85!&=PNO@h!&%9%/%j%W%H$N%j%F%i%k$,A4$FNc$($Pe(B CP932 e$B$N>l9g!"e(B
|Ruby 1.9 e$B$G$OF~NO$H%j%F%i%k$r7k9g$G$-$^$;$s!#e(B
|e$B$3$l$,!"e(BPerl e$BEy$N>l9g$O%j%F%i%k$bJQ49$7$F$7$^$&$N$GLdBj$J$$$N$G$9$,!"e(B
|Ruby 1.9 e$B$G$Oe(B e$B%j%F%i%k$O$=$N$^$^$J$N$GIT0lCW$,H/@8$7$^$9!#e(B
|
|oneliner e$BEy$N4JC1$J%9%/%j%W%H$G%j%F%i%k$r$=$N$^$^G’<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Bdefault_externale$B$Ge(B
e$B$9$+$M!#$^$”!"$=$l$O$=$l$G$R$H$D$NA*Br;h$@$H$O;W$$$^$9!#e(B

|> * e$B4pK\e(BUTF-8e$B$rJV$;$P$h$$!"F~NO$be(BUTF-8e$B$r4|BTe(B
|> * e$B$h$j?F@Z$J%i%$%V%i%j$Oe(Bdefault_internale$B$GJV$9!#F~NO$Oe(B
|> encodinge$B$r8+$FBP=he(B
|
|default_internal e$B$,6u$N>l9g$Oe(B default_external e$B$GJV$9$N$G$9$+$M!#e(B

e$B$=$&$G$9!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

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

In message “[ruby-dev:36533] Re: Encoding.default_internal
e$B$N$?$a$N%Q%C%Ae(B”
on Sep.25,2008 06:19:21, [email protected] wrote:
| e$B8D?ME*$K$O!Ve(BUTF-16e$B"*e(BUTF-8e$B"e(BUTF-16e$B!W%b%G%k$G==J,$G$“$j!”$+$De(B
| ASCIIe$B8_49LdBj$r2sHr$G$-$k$3$H$N4r$7$5$NJ}$,Bg$-$$$H;W$C$F$$$ke(B
| e$B$N$G$9$,e(B(e$B@55,I=8=$H$+$bHf3SE
<+A3$K;H$($k$h$&$K$J$k$7e(B)e$B!“$$$d!“e(B
| e$B$=$l$G$be(BUTF-16e$B$r$=$N$^$^JQ49$J$7$K07$($kJ}$,NI$$$N$@$H$$$&$3e(B
| e$B$H$G$”$l$P!”$<$R;XE&$7$F$/$@$5$$!#e(B

e$B$“$s$^$j$3$&$$$&$3$H$r8@$&$N$O9%$-$G$O$J$$$N$G$9$,!”<B9TB.EYe(B
e$B$N%m%9$,GO</$K$J$j$^$;$s!#e(B
100MBe$B$Ne(BUTF-16LEe$B$J%F%-%9%H$+$i@55,I=8=%^%C%A$GI,MW$J9T$rH4$-=Pe(B
e$B$9$H$$$&=hM}$r9T$C$F$$$?$N$G$9$,!"e(BUTF-8e$B$X$NJQ49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!#e(B
    default_internale$B$O!Ve(BUTF-8e$B!W!#e(B

  • e$B?7@_$Ne(B-Le$B%*%W%7%g%s$r;XDj$9$k$He(Bdefault_externale$B$Oe(Blocalee$B!"e(B
    default_internale$B$O6u$K$J$k!#e(B

e$B$3$l$O$3$N$^$^$@$H$^$:$$$G$9!#e(B
e$B$9$Y$F$,e(B UTF-8 e$B$J$i$P8@$&$^$G$bLdBj$"$j$^$;$s!#e(B
e$B$7$+$7!"F~NO85!&=PNO@h!&%9%/%j%W%H$N%j%F%i%k$,A4$FNc$($Pe(B CP932 e$B$N>l9g!"e(B
Ruby 1.9 e$B$G$OF~NO$H%j%F%i%k$r7k9g$G$-$^$;$s!#e(B

e$B$3$l$O:,K\E*$JLdBj$J$N$+!“!Ve(B-L e$B$r;XDj$7$J$$8B$j!W$J$N$+e(B?
e$B8e<T$@$H;W$$$^$9$,!”@.@%$5$s!"3NG’$G$-$^$9$+!#e(B

e$B$3$l$,!"e(BPerl e$BEy$N>l9g$O%j%F%i%k$bJQ49$7$F$7$^$&$N$GLdBj$J$$$N$G$9$,!"e(B
Ruby 1.9 e$B$G$Oe(B e$B%j%F%i%k$O$=$N$^$^$J$N$GIT0lCW$,H/@8$7$^$9!#e(B

oneliner e$BEy$N4JC1$J%9%/%j%W%H$G%j%F%i%k$r$=$N$^$^G’<1$5$;$?$$>l9g$K!"e(B
-L e$B0l$D$H$O$$$(%*%W%7%g%s$,I,MW$H$$$&$N$OHQ;($G$O$J$$$G$7$g$&$+!#e(B

e$B$=$&$G$9$M!#e(B

e$B$3$l$N0l$D$N2r7h:v$O%j%F%i%k$be(B default_internal e$B$KJQ49$7$F$7$^$&$3$H$G$9!#e(B

e$B$b$&0l$D$Oe(B default_internal e$B$N=i4|CM$r6u$K$7!"e(B
Unicoder e$BMQ$N%*%W%7%g%s$r?7@_$9$k$3$H$G$9e(B (e$B9,$$e(B -U e$B$,6u$$$F$$$^$9e(B)e$B!#e(B

e$B$3$l$O$$$$%“%$%G%#%”$@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J$s$8$c$J$$$+$H;W$$$^$9!#e(B

e$B$3$l$OHyL/$JLdBj$G$9!#$J$<$J$iJQ49$G$-$J$$$N$O7k9=>/$J$/!“e(B
e$B$?$^$K$7$+5/$3$i$J$$LdBj$3$=Fq$7$$LdBj$O$”$j$^$;$s!#e(B

e$B$3$N7k2L!"3F<o%i%$%V%i%j$Oe(B

  • e$B4pK\e(BUTF-8e$B$rJV$;$P$h$$!"F~NO$be(BUTF-8e$B$r4|BTe(B
  • e$B$h$j?F@Z$J%i%$%V%i%j$Oe(Bdefault_internale$B$GJV$9!#F~NO$Oe(B
    encodinge$B$r8+$FBP=he(B

e$B$3$3$O$A$g$C$H?4G[$N$H$3$m$G$9!#FC$K309q$N%W%m%0%i%^$Oe(B
e$B!VA4Ite(B UTF-8 e$B$G$d$C$F$7$^$&!WF08~$,6/$$$G$7$g$&!#e(B
e$B$=$l$G$$$$$H$$$&2DG=@-$b$“$j$^$9$,!”$=$&$G$O$J$$2DG=@-$be(B
e$B$"$j$^$9!#e(B

default_internal e$B$,6u$N>l9g$Oe(B default_external e$B$GJV$9$N$G$9$+$M!#e(B

e$B%Q%C%A$r:n$C$?$H$-$K!"!Ve(Bdefault_internal e$B$,6u$J$ie(B
default_externale$B!We(B
e$B$rJV$95!G=$NI,MW@-$r46$8;O$a$^$7$?!#e(B

e$B59$7$/$*4j$$$7$^$9!#e(B Martin.

#-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-# http://www.sw.it.aoyama.ac.jp mailto:[email protected]

At 00:39 08/09/25, Tanaka A. wrote:

Encoding.default_internal = ‘utf-8’
# tested with ‘utf-8’, ‘shift_jis’, and ‘euc-jp’

e$BJQ992DG=$H$9$k$3$H$K$D$$$F$O!"%9%l%C%I%;!<%U$G$J$$$3$H$K2??Me(B
e$B$b7|G0$rI=L@$7$F$$$^$9$M!#;d$b4m$&$$$H;W$$$^$9!#e(B

e$B%9%l%C%IKh$K$9$k$K$OLdBj$J$$$H;W$$$^$9!#$7$+$7e(B default_external
e$B$b8=:_%9%l%C%IKh$K$J$C$F$J$$$G$9$h$M!#<BAuE*$K$OFq$7$$$G$7$g$&$+!#e(B

e$B$^$?!“JQ49$9$k$N$K$O$=$l$O$=$l$G6lO+$,$”$k$s$8$c$J$$$G$7$g$&e(B
e$B$+!#e(B

e$B$?$H$($P!"e(BPython 3000 e$B$G$O!“e(Bargv e$B$KJQ$J%P%$%HNs$,M?$($i$l$?e(B
e$B>l9g$K5/F0;~$K%(%i!<$K$J$k$H$$$&OC$,$”$j$^$7$?!#e(B
[Python-3000] Unicode and OS strings
(e$B8=:_$I$&$J$C$F$$$k$+$O3NG’$7$F$$$^$;$s!#e(B)

e$BJQ49$9$k$H$$$&$3$H$O<:GT$9$k2DG=@-$,M-$k$o$1$G!“<:GT$r$&$^$/e(B
e$B07$($k$+9M$($F$_$kI,MW$,$”$k$N$G$O$J$$$G$7$g$&$+!#e(B

e$B$=$&$G$9$M!#e(Bargv e$B$NJQ49$G$-$J$$$b$N$re(B ASCII-8BIT
e$B$K$9$k$N$Oe(B

  • e$B$=$3$^$GBP1~$9$kI,MW$,$"$k>l9g!"BP1~$G$-$ke(B
  • e$BBP1~$7$J$$$H$$$:$l$I$3$+%(%i!<$K$J$ke(B
    e$B$H$$$&0UL#$G3d$j$H$$$$$?$$:v$@$H;W$$$^$9!#e(B

e$B59$7$/$*4j$$$7$^$9!#e(B Martin.

#-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-# http://www.sw.it.aoyama.ac.jp mailto:[email protected]

e$B$J$+$`$i$5$s!"$3$s$K$A$O!#e(B

e$B0lHLE*$K$Oe(B Ruby e$B$Ne(B UTF-16 e$B$N=hM}$OB.$/$“$j$^$;$s!#e(B
e$B$J$<$J$ie(B 1e$B%P%$%H$4$H$K=hM}$7$F$$$^$9!#e(B
[e$B54<V$O$=$N$X$s0c$&$+$b$7$l$^$;$s!#e(B]
e$B99$K!“JQ49$O!VJ8;z$4$H$K>.$5$$4X?t$r8F$V!W$3$He(B
e$B$K$J$C$F$$$^$9$N$G!”$=$N$?$a$KCY$$$H$$$&2DG=@-e(B
e$B$b$”$j$^$9!#e(B(e$B$=$&$G$J$$2DG=@-$b$“$j$^$9e(B)
e$B$=$l0J30$K$b9M$($i$l$k$3$H$OMM!9e(B (e$BNc$($P@55,I=8=e(B
e$B$,$I$N$0$i$$J#;($b$N$J$N$+e(B) e$B$J$N$G!”$b$7$b$&>/$7e(B
e$B>$7$$>pJs$,$"$j$^$7$?$i@'Hs65$($F$/$@$5$$!#e(B

e$B59$7$/$*4j$$$7$^$9!#e(B Martin.

At 07:12 08/09/25, U.Nakamura wrote:

e$B$“$s$^$j$3$&$$$&$3$H$r8@$&$N$O9%$-$G$O$J$$$N$G$9$,!”<B9TB.EYe(B
e$BI,MW$,$“$k$o$1$G3N$+$K$”$s$^$j<+A3$8$c$J$$$G$9$,!"$@$+$i@[email protected](B
e$B$G$-$J$$J}$,%^%7$H$$$&$[$IIT<+A3$H$O;W$C$F$$$^$;$s!#<g4Q$G$9e(B
e$B$1$I!#e(B

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

U.Nakamura [email protected]

#-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-# http://www.sw.it.aoyama.ac.jp mailto:[email protected]

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

In message “[ruby-dev:36545] Re: Encoding.default_internal
e$B$N$?$a$N%Q%C%Ae(B”
on Sep.25,2008 10:38:35, [email protected] wrote:

e$B0lHLE*$K$Oe(B Ruby e$B$Ne(B UTF-16 e$B$N=hM}$OB.$/$“$j$^$;$s!#e(B
e$B$J$<$J$ie(B 1e$B%P%$%H$4$H$K=hM}$7$F$$$^$9!#e(B
[e$B54<V$O$=$N$X$s0c$&$+$b$7$l$^$;$s!#e(B]
e$B99$K!“JQ49$O!VJ8;z$4$H$K>.$5$$4X?t$r8F$V!W$3$He(B
e$B$K$J$C$F$$$^$9$N$G!”$=$N$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$9$+$i!"e(B1.8e$B$+$i$N%i%$%V%i%j$N0\9T$r>/$7$@$1:$Fq$K$7e(B
e$B$^$9!#e(B

e$B$^$?!"e(Bdefault_internale$B$,e(Bnile$B$G$J$$$H$-$Ke(B

open(path, “r:default_external”)

e$B$,e(B

open(path, “r:default_external:default_internal”)

e$B$H2r<a$5$l$k$3$H$O$J$$$N$G$9$Me(B?
"mode:external:internal"e$B$,4pK\7A$G!"e(B
e$B>JN,$9$k$H%G%U%)%k%H$,F~$k$H$$$&;EMM$N$[$&$,J,$+$j$d$9$$$H46$8$^$9!#e(B

e$B$?$@$7!"$=$N$h$&$K$9$k$He(Bdefault_externale$B$r$=$N$^$^<h$j9~$`$3$H$r4|BT$7$Fe(B
e$B$$$kJ8;zJQ49=hM}7O$N%i%$%V%i%j$O3+$$$?$"$H$K99$Ke(Binternale$B$r@_Dj$7$J$$$H$$e(B
e$B$1$J$/$J$C$FLLE]$K$J$k!"$H$$$&LdBj$O$"$j$^$9!#e(B

e$B$=$3$G!"3+H/2q5D$G$*OC$7$7$?$h$&$Je(B
Encoding.with_internal(Encoding::UTF8) {
open(path, “r:external”)
}

e$B$_$?$$$J$d$jJ}$d%^%8%C%/%3%a%s%H$G;XDj$9$k$H$$$&$d$jJ}$"$k$o$1$G$9$1$l$Ie(B
e$B$b!#$3$l$O$3$l$GJ#;($G$9$h$M!#FCDj$NJQ49$r!"$"$k$$$OJQ49$5$l$J$$$3$H$r4|e(B
e$BBT$9$k%i%$%V%i%j<BAu$O$I$N$h$&$K$7$?$i$h$$$b$N$G$7$g$&$+!#e(B

e$B$J$+$@$G$9!#e(B

At Thu, 25 Sep 2008 00:49:10 +0900,
Yukihiro M. wrote in [ruby-dev:36523]:

  • default_internale$B$Oe(BIOe$B$Ge(Binternale$B$r;XDj$7$J$+$C$?>l9g$N%(%s%3!<e(B
    e$B%G%#%s%0$G$"$ke(B
  • e$B$3$l$,;XDj$5$l$F$$$k;~e(BIOe$B$+$i$NF~NO$Oe(B(e$B%P%$%J%j$G$J$$8B$je(B)e$B!"e(B
    e$B$3$N%(%s%3!<%G%#%s%0$r;}$De(B(e$BI,MW$J$iJQ49$9$ke(B)e$B!#e(B

e$BJQ49$r$5$;$k$J$iJQ49$r;XDj$9$k$[$&$,$$$$$s$8$c$J$$$G$7$g$&$+!#$?e(B
e$B$H$($Pe(Binternale$B$r6u$K$7$?$H$-$K$Oe(Bdefaulte$B$r;H$&$H$+!#e(B

e$B$N$h$&$K=q$/!#5U$Ke(Bdefault_internale$B$X$NJQ49$rM^@)$9$k$?$a$Ke(B
e$B$O!"6u$Ne(Bdefault_internale$B$r;XDj$7$Fe(B

-E iso-2022-jp:

e$B$N$h$&$K=q$/!#5lMh$N!Ve(B-E euc-jpe$B!W$O!Ve(B-E euc-jp:e$B!W$HF1$80Ue(B
e$BL#$K$J$k!#e(B

e$B!Ve(B:e$B!W$J$7$Ge(B -E euc-jp
e$B$J$I$H;XDj$7$?>l9g$O$I$&$J$k$s$G$7$g$&$+!#e(B
e$B$^$?!"e(Binternale$B$He(Bexternale$B$=$l$>$l$@$1$r;XDj$9$k%*%W%7%g%s$rJ#?t;Xe(B
e$BDj$7$?>l9g$H$+!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:36535] Re: Encoding.default_internal
e$B$N$?$a$N%Q%C%Ae(B”
on Thu, 25 Sep 2008 06:39:14 +0900, Hidetoshi NAGAI
[email protected] writes:

|> e$B:#F|0lF|9M$($F!“F3F~$9$k$3$H$K$7$^$7$?!#e(B
|
|e$B:Y$+$$;EMM$K4X$7$F$O?'!9$H0U8+$O$”$k$h$&$G$9$,!$e(B
|e$B;d<+?H$O>/$J$/$H$be(B default_internal e$B$NF3F~<+BN$O4?7^$7$^$9!%e(B
|
|# e$B@N$*4j$$$7$?$1$l$I$b!V%0%m!<%P%k$J>uBV$OF~$l$J$$!W$H$$$&$3$H$Ge(B
|# e$B6/$/5q@d$5$l$?$b$N$H;w$F$$$k$h$&$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G!$e(B
|default_internal e$B$,6u$G$”$k$J$ie(B default_extenral e$B$Ge(B
|e$BJV$9$h$&$K$9$k$H$$$&$N$,4pK$G$7$g$&$+!)e(B

e$B$O$$!#$=$&$J$j$^$9!#>e5-$N$[$+$K%i%$%V%i%j$K$h$C$F$O!“M?$($ie(B
e$B$l$?%G!<%?e(B(e$BJ8;zNse(B)e$B$N%(%s%3!<%G%#%s%0$r$=$N$^$^JV$9$H$$$&%*%&e(B
e$B%`JV$7%?%$%W$N$b$N$,$”$j$($k$G$7$g$&$M!#e(B

|e$B3HD%%i%$%V%i%jB&$Oe(B core e$B$N;EMM$,3NDj$7$J$$$HF0$-$E$i$$$G$9!%e(B
|e$B$G!$e(Bfeature freeze e$B$,6a$E$$$F$+$ie(B core e$B$,?'!9$H$$$8$i$l$k$He(B
|e$BBP1~$,A4$/4V$K9g$$$^$;$s!%e(B
|
|# e$B!V$9$Y$F$NJQ99$KB(:B$KBP1~$7B3$1$k!W$H$$$&$N$O!$e(B
|# e$B$5$9$,$K$4MF<O$r!%e(B(^_^)
|
|e$B$b$72DG=$G$"$k$J$i!$%j%j!<%9%9%1%8%e!<%k$K$*$$$F!$e(B
|core e$B$Ne(B feature freeze e$B$+$ie(B ext e$B$Ne(B feature freeze e$B$^$G$Ke(B
|e$B>/$74V$r6u$1$F$$$?$@$1$k$H=u$+$j$^$9!%e(B

e$B$3$l$K$D$$$F$b?=$7Lu$J$/;W$$$^$9!#e(BYuguie$B$5$s$H$O$^$@$A$c$s$He(B
e$BOC$7$F$$$^$;$s$,!":#2s$NJQ99$K$D$$$F$NBP1~$Oe(Bfreezee$B$NBP>]$G$Oe(B
e$B$J$$$H$$$&$3$H$K$G$-$?$i$$$$$H;W$C$F$$$^$9!#$G$-$l$Pe(B1e$B%v7n$/e(B
e$B$i$$$N4|4V$G!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:36548] Re: Encoding.default_internal
e$B$N$?$a$N%Q%C%Ae(B”
on Thu, 25 Sep 2008 12:16:10 +0900, “Yugui (Yuki S.)”
[email protected] writes:

|> open(path, “r”)
|> e$B$Oe(B
|> open(path, “r:default_external”)
|> e$B$H2r<a$5$l$^$9!#e(Bnile$B$G$J$$;~!"e(B
|>
|> open(path, “r:default_external:internal_encoding”)
|
|e$B$3$l$O!"e(Bdefault_internale$B$,e(Bnile$B$G$J$$%W%m%;%9$+$ie(Brequiree$B$5$l$?%i%$%V%i%je(B
|e$B$,!"e(Bopen(path, “r”)e$B$K$h$C$F85$N%j%=!<%9$H$O%P%$%HNs$H$7$F0[$J$k$b$N$rF@e(B
|e$B$k$3$H$K$J$j$^$9!#$G$9$+$i!"e(B1.8e$B$+$i$N%i%$%V%i%j$N0\9T$r>/$7$@$1:$Fq$K$7e(B
|e$B$^$9!#e(B

e$B$=$&$G$9$M!#$=$l$O;v<B$G$9!#e(B

|e$B$^$?!"e(Bdefault_internale$B$,e(Bnile$B$G$J$$$H$-$Ke(B
|
| open(path, “r:default_external”)
|
|e$B$,e(B
|
| open(path, “r:default_external:default_internal”)
|
|e$B$H2r<a$5$l$k$3$H$O$J$$$N$G$9$Me(B? "mode:external:internal"e$B$,4pK\7A$G!"e(B
|e$B>JN,$9$k$H%G%U%)%k%H$,F~$k$H$$$&;EMM$N$[$&$,J,$+$j$d$9$$$H46$8$^$9!#e(B

e$B$3$l$O$=$N$h$&$K2r<a$5$l$?J}$,NI$$$H;W$$$^$9!#$D$^$j!"e(B

| open(path, “r:default_external”)
|e$B$,e(B
| open(path, “r:default_external:default_internal”)

e$B$H$$$&$3$H$G$9!#e(B

|e$B$?$@$7!“$=$N$h$&$K$9$k$He(Bdefault_externale$B$r$=$N$^$^<h$j9~$`$3$H$r4|BT$7$Fe(B
|e$B$$$kJ8;zJQ49=hM}7O$N%i%$%V%i%j$O3+$$$?$”$H$K99$Ke(Binternale$B$r@_Dj$7$J$$$H$$e(B
|e$B$1$J$/$J$C$FLLE]$K$J$k!“$H$$$&LdBj$O$”$j$^$9!#e(B

e$B$=$NLdBj$O$"$j$^$9$M!#e(B

|e$B$=$3$G!“3+H/2q5D$G$*OC$7$7$?$h$&$Je(B
|Encoding.with_internal(Encoding::UTF8) {
| open(path, “r:external”)
|}
|
|e$B$_$?$$$J$d$jJ}$d%^%8%C%/%3%a%s%H$G;XDj$9$k$H$$$&$d$jJ}$”$k$o$1$G$9$1$l$Ie(B
|e$B$b!#$3$l$O$3$l$GJ#;($G$9$h$M!#FCDj$NJQ49$r!“$”$k$$$OJQ49$5$l$J$$$3$H$r4|e(B
|e$BBT$9$k%i%$%V%i%j<BAu$O$I$N$h$&$K$7$?$i$h$$$b$N$G$7$g$&$+!#e(B

e$B$A$g$C$H6l$7$$$G$9$,!"e(B

open(path, “r:default_external:”)

e$B$C$F$N$O$I$&$G$7$g$&$+$M!#$“$”!“$”$He(B

open(path, “r:ascii-8bit”)

e$B$@$1$Oe(Bdefault_internale$B$,$J$s$G$"$m$&$H$=$N$^$^FI$_9~$s$@J}$,e(B
e$B$h$$$G$7$g$&$M!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

At 14:30 08/09/25, Nobuyoshi N. wrote:

e$B$J$+$@$G$9!#e(B

At Thu, 25 Sep 2008 00:49:10 +0900,
Yukihiro M. wrote in [ruby-dev:36523]:

e$B$N$h$&$K=q$/!#5U$Ke(Bdefault_internale$B$X$NJQ49$rM^@)$9$k$?$a$Ke(B
e$B$O!"6u$Ne(Bdefault_internale$B$r;XDj$7$Fe(B

-E iso-2022-jp:

e$B$N$h$&$K=q$/!#5lMh$N!Ve(B-E euc-jpe$B!W$O!Ve(B-E euc-jp:e$B!W$HF1$80Ue(B
e$BL#$K$J$k!#e(B

e$B!Ve(B:e$B!W$J$7$Ge(B -E euc-jp e$B$J$I$H;XDj$7$?>l9g$O$I$&$J$k$s$G$7$g$&$+!#e(B

e$BD>A0$K=q$$$?$h$&$Ke(B -E euc-jp: e$B$HF1$80UL#$K$J$k!#e(B

e$B$^$?!"e(Binternale$B$He(Bexternale$B$=$l$>$l$@$1$r;XDj$9$k%*%W%7%g%s$rJ#?t;Xe(B
e$BDj$7$?>l9g$H$+!#e(B

e$B3N$+$K!“Nc$($P%3%^%s%I%i%$%s$Ge(B -E
shift_jise$B!”%9%/%j%W%H$NCf$Ge(B
#!/usr/bin/ruby -E :utf-8 e$B$H$+$H$$$&AH$_9g$o$;$r9M$($J$$$He(B
e$B$$$1$^$;$s$h$M!#e(B

e$B59$7$/$*4j$$$7$^$9!#e(B Martin.

#-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-# http://www.sw.it.aoyama.ac.jp mailto:[email protected]