Non-locale filename encoding

Dir e$B$N;H$$$+$?$H$7$F!"%U%!%$%kL>$N%(%s%3!<%G%#%s%0$,e(B locale
encoding e$B$K=>$C$F$$$k$H$O2>Dj$;$:$K!"%W%m%0%i%`$,$,$s$P$k$He(B
e$B$-$NOC$G$9$,!"8=>u$Ne(B Dir e$B$Ne(B internal_encoding,
external_encoding e$B$H$$$&5!9=$OE,@Z$J$b$N$G$O$J$$$h$&$K;W$$$^e(B
e$B$9!#e(B

e$B%W%m%0%i%$,$,$s$P$k$H$$$&0U?^$@$H$9$l$P!"e(BRuby e$B$K4|BT$5$l$ke(B e$B$N$O!"$I$N%W%i%C%H%U%)!<%$G$b3N<B$K%U%!%$%k$rF1Dj$G$-$ke(B
string e$B$rF@$k$H$$$&%$%s%?!<%U%’!<%9$G$7$g$&!#e(B

e$B6qBNE*$K$$$($P!“e(BWindows e$B$G$Oe(B UTF-16LE e$B$”$k$$$Oe(B UTF-8
e$B$Ne(B
string e$B$,F@$i$l!"e(BUnix e$B$G$OJQ49$5$l$F$$$J$$%P%$%HNse(B (e$B$Ke(B
locale encoding e$B$r$D$1$?e(B string) e$B$,F@$i$l$k$3$H$,4|BT$5$l$^e(B
e$B$9!#e(B
(Unix e$B$N>l9g$KIU$1$k%(%s%3!<%G%#%s%0$Oe(B locale encoding e$B$G$Je(B
e$B$/$F!“e(Bascii-8bit e$B$H$$$&$N$b$”$j$&$k$+$b$7$l$^$;$s$,e(B)

e$B$7$+$7!“e(Binternal_encoding, external_encoding e$B$G$O!”%W%i%C%He(B
e$B%U%)!<%`$K$h$C$FJQ$o$k!"$=$&$$$&;XDj$O$G$-$J$$$h$&$K8+$($^$9!#e(B

e$BI,MW$J$N$O!"%W%m%0%i%`$,$,$s$P$k$+$i$J$k$Y$/@8$N$^$^$N%U%!%$e(B
e$B%kL>$r$h$3$;!"$H$$$&0U?^$rEA$($k%*%W%7%g%s$G$O$J$$$G$7$g$&$+!#e(B

e$B$^$?!“e(Binternal_encoding, external_encoding e$B$C$F!”$I$N$/$i$$e(B
e$BLr$KN)$D$s$G$7$g$&$+!#e(B

e$B%7%9%F%`$rC10le(B locale e$B$G1?MQ$7$F$$$k$H$-$O2?$b;XDj$9$kI,MW$,e(B
e$BM-$j$^$;$s$7!"e(Blocale e$B$KMj$i$J$$$H$-$O>e5-$N$h$&$KLr$KN)$A$^e(B
e$B$;$s!#e(B

e$B$^$?!"JQ49$re(B Dir e$B$NCf$G9T$&$H!“JQ49A0$Ne(B string
e$B$,%”%W%j%1!<e(B
e$B%7%g%s$KM?$($i$l$^$;$s!#$=$&$9$k$H!"e(B(e$B>/$J$/$H$be(B Unix
e$B$G$Oe(B)
open e$B$J$I$KI,MW$Je(B string e$B$,F@$i$l$J$$$3$H$K$J$j$^$9!#e(B

e$B$"$H!"@8$N$^$^$N%U%!%$%kL>$,F@$i$l$l$P!“e(BString#encode e$B%a%=%Ce(B
e$B%I$GF1MM$NJQ49$O%”%W%j%1!<%7%g%sB&$G<BAu2DG=$G$9!#e(B

internal_encoding, external_encoding e$B$C$F!"$I$&$$$&%"%W%j%1!<e(B
e$B%7%g%s$GLr$KN)$D$s$G$7$g$&e(B?

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

Tanaka A. wrote:

Dir e$B$N;H$$$+$?$H$7$F!"%U%!%$%kL>$N%(%s%3!<%G%#%s%0$,e(B locale
encoding e$B$K=>$C$F$$$k$H$O2>Dj$;$:$K!"%W%m%0%i%`$,$,$s$P$k$He(B
e$B$-$NOC$G$9$,!"8=>u$Ne(B Dir e$B$Ne(B internal_encoding,
external_encoding e$B$H$$$&5!9=$OE,@Z$J$b$N$G$O$J$$$h$&$K;W$$$^e(B
e$B$9!#e(B

e$B$"$^$j%W%m%0%i%`$K$,$s$P$i$;$?$/$J$$$J$!$H;W$C$F$$$k$N$G$9$,!“e(B
e$B$$$A$$$A0z?t$rM?$($”$j!"e(BRuby e$B<+BN$,$,$s$P$k$N$b$=$NCf$KF~$ke(B
e$B$H$$$&<gD%$b@.$jN)$D$N$G$7$g$&$M$’!#e(B

e$B%W%m%0%i%$,$,$s$P$k$H$$$&0U?^$@$H$9$l$P!"e(BRuby e$B$K4|BT$5$l$ke(B e$B$N$O!"$I$N%W%i%C%H%U%)!<%$G$b3N<B$K%U%!%$%k$rF1Dj$G$-$ke(B
string e$B$rF@$k$H$$$&%$%s%?!<%U%’!<%9$G$7$g$&!#e(B

e$B$3$NI,MW@-$OM}2r$7$^$9!#e(B

e$B6qBNE*$K$$$($P!“e(BWindows e$B$G$Oe(B UTF-16LE e$B$”$k$$$Oe(B UTF-8 e$B$Ne(B
string e$B$,F@$i$l!"e(BUnix e$B$G$OJQ49$5$l$F$$$J$$%P%$%HNse(B (e$B$Ke(B
locale encoding e$B$r$D$1$?e(B string) e$B$,F@$i$l$k$3$H$,4|BT$5$l$^e(B
e$B$9!#e(B
(Unix e$B$N>l9g$KIU$1$k%(%s%3!<%G%#%s%0$Oe(B locale encoding e$B$G$Je(B
e$B$/$F!“e(Bascii-8bit e$B$H$$$&$N$b$”$j$&$k$+$b$7$l$^$;$s$,e(B)

e$B$7$+$7!“e(Binternal_encoding, external_encoding e$B$G$O!”%W%i%C%He(B
e$B%U%)!<%`$K$h$C$FJQ$o$k!"$=$&$$$&;XDj$O$G$-$J$$$h$&$K8+$($^$9!#e(B

e$B$G$-$^$;$s$M!#e(B

e$B$7$+$7!"<B:]$N$H$3$m!“8=:_<+F0JQ49$,9T$o$l$k$N$Oe(B
Windows e$B$/$i$$$J$o$1$Ge(B (e$B$3$l$b8!F$Cf$G$O$”$ke(B)e$B!"e(B
e$B$?$$$F$$$N>l9g$OF0:n$,JQ$o$i$J$$$o$1$G$9!#e(B

e$B$H$9$k$H!“EDCf$5$s$NDs0F$O!”%G%U%)%k%H$r$b$C$H<+F0JQ49B&$Ke(B
e$BE]$7$?>l9g$K??2A$rH/4x$9$k$N$G$9$+$M!#e(B

e$B$^$?!"JQ49$re(B Dir e$B$NCf$G9T$&$H!“JQ49A0$Ne(B string e$B$,%”%W%j%1!<e(B
e$B%7%g%s$KM?$($i$l$^$;$s!#$=$&$9$k$H!"e(B(e$B>/$J$/$H$be(B Unix e$B$G$Oe(B)
open e$B$J$I$KI,MW$Je(B string e$B$,F@$i$l$J$$$3$H$K$J$j$^$9!#e(B

e$B$"$H!"@8$N$^$^$N%U%!%$%kL>$,F@$i$l$l$P!“e(BString#encode e$B%a%=%Ce(B
e$B%I$GF1MM$NJQ49$O%”%W%j%1!<%7%g%sB&$G<BAu2DG=$G$9!#e(B

internal_encoding, external_encoding e$B$C$F!"$I$&$$$&%"%W%j%1!<e(B
e$B%7%g%s$GLr$KN)$D$s$G$7$g$&e(B?

e$BEv;~$O$"$^$jL@<(E*$Ke(B force_encoding / encode
e$B$5$;$?$/$J$$$H$$$&<q;]$G$7$?!#e(B
e$B7k6I$N$H$3$m!"%W%m%0%i%`$G4hD%$i$;$k$Y$-$+!"e(B
e$B@_Dj$N<jCJ$r$9$k$Y$-$+$H$$$&=j$J$N$G$9$+$M$’!#e(B

e$B$D$^$k$H$3$m!"Nc30$,=P$?;~$N=hM}$NMxJX@-$+e(B

In article [email protected],
“NARUSE, Yui” [email protected] writes:

e$B$"$^$j%W%m%0%i%`$K$,$s$P$i$;$?$/$J$$$J$!$H;W$C$F$$$k$N$G$9$,!“e(B
e$B$$$A$$$A0z?t$rM?$($”$j!"e(BRuby e$B<+BN$,$,$s$P$k$N$b$=$NCf$KF~$ke(B
e$B$H$$$&<gD%$b@.$jN)$D$N$G$7$g$&$M$'!#e(B

Dir e$B$Ne(B internal_encoding, external_encoding e$B$r;H$&$K$O!"%W%me(B
e$B%0%i%`$,JQ$JJ}8~$K$,$s$P$kI,MW$,M-$k$h$&$K;W$($^$9!#e(B

e$B$7$+$7!"<B:]$N$H$3$m!“8=:_<+F0JQ49$,9T$o$l$k$N$Oe(B
Windows e$B$/$i$$$J$o$1$Ge(B (e$B$3$l$b8!F$Cf$G$O$”$ke(B)e$B!"e(B
e$B$?$$$F$$$N>l9g$OF0:n$,JQ$o$i$J$$$o$1$G$9!#e(B

e$B$H$9$k$H!“EDCf$5$s$NDs0F$O!”%G%U%)%k%H$r$b$C$H<+F0JQ49B&$Ke(B
e$BE]$7$?>l9g$K??2A$rH/4x$9$k$N$G$9$+$M!#e(B

e$B$$$$$(!#e(B

e$B$?$H$($P!“$”$k%G%#%l%/%H%j$N3F%U%!%$%k$N%5%$%:$rI=<($9$k$3$He(B
e$B$r9M$($F$_$^$7$g$&!#e(B

% mkdir /tmp/xyz
% cd /tmp/xyz
% ruby -e ‘open(“\x91\x92\x93\x94”, “w”)’
% ls
???

e$B$3$3$G!"%(%s%3!<%G%#%s%0$r;XDj$7$J$1$l$P!"0J2<$N$h$&$K$J$j$^e(B
e$B$9!#e(B

% ruby -e ’
Dir.open(“.”) {|d|
while n = d.read
p [File.size(n), n]
end
}’
[4096, “.”]
[45056, “…”]
[0, “\x91\x92\x93\x94”]

e$B$3$N%W%m%0%i%`$O!“e(BUnix e$B$G$OG$0U$N%U%!%$%kL>$K$D$$$FF0:n$7$^e(B
e$B$9!#$?$H$($P!”>e5-$Ne(B \x91\x92\x93\x94 e$B$G$bF0$-$^$9!#e(B

e$B$7$+$7!“e(BWindows e$B$G!“e(BUnicode
e$B$K$O$”$k$,!”%7%9%F%`%3!<%I%Z!<%8e(B
e$B$G$OI=8=$G$-$J$$J8;ze(B (e$BF|K\8lHGe(B Windows
e$B$N>l9g$G$$$($P!“e(BCP932
e$B$G$OI=8=$G$-$J$$J8;ze(B) e$B$,%U%!%$%kL>$K;H$o$l$F$$$k$H!”$*$=$i$/e(B
e$BF0$+$J$$$G$7$g$&!#e(B

Windows e$B$G$=$&$$$&%U%!%$%kL>$b07$*$&$H9M$($?>l9g!"8=;~E@$G$O!"e(B
Ruby e$B$K$O$=$N$?$a$N5!9=$,F~$C$F$$$J$$$N$G$I$&;XDj$9$k$+$OL@e(B
e$B$i$+$G$OM-$j$^$;$s$,!"2>$K!"e(B:external_encoding=>“utf-16le”
e$B$H$9$k$He(B Unicode e$B$J%U%!%$%kL>$r07$&$h$&$K$J$j!"e(B
:external_encoding=>“utf-16le”, :internal_encoding=>“utf-8”
e$B$H$9$k$H$=$l$re(B UTF-8 e$B$K$7$F$o$?$7$F$/$l$k$7$F$_$^$7$g$&!#e(B
e$B$=$&$9$k$H<!$N$h$&$K$J$j$^$9!#e(B

% ./ruby -e ’
Dir.open(“.”, :external_encoding=>“utf-16le”,
:internal_encoding=>“utf-8”) {|d|
while n = d.read
p [File.size(n), n]
end
}’
-e:3:in read': invalid byte sequence (RuntimeError) from -e:3:in block in ’
from -e:2:in open' from -e:2:in

e$B$7$+$7!“;DG0$J$3$H$K!”$3$l$Oe(B Unix e$B$G$OF0$-$^$;$s!#e(B
e$BD>@\E*$K$O!“>e5-$N%(%i!<$O!“e(B”.” e$B$re(B UTF-16LE e$B$+$ie(B UTF-8
e$B$KJQe(B
e$B49$7$h$&$H$7$FH/@8$7$F$$$^$9!#e(B

e$B$^$?!"2>$KJQ49%(%i!<$,5/$-$J$+$C$?$H$7$F$b!"0lHL$KJQ49$r9T$&e(B
e$B$H%P%$%HNs$,JQ2=$7$^$9!#$7$+$7!“e(BFile.size e$B$O%U%!%$%k$r$A$c$se(B
e$B$HF1Dj$9$kI,MW$,$”$j$^$9!#$H$9$k$H!"5UJQ49$,I,MW$K$J$j$^$9$,!“e(B
e$B0lHL$KJQ49!&5UJQ49$G%P%$%HNs$,e(B round trip e$B$9$kJ]>Z$O$”$j$^$;e(B
e$B$s!#e(B

e$BL@$i$+$J%1!<%9$H$7$F$O!“e(BGB18030 e$B$,$”$2$i$l$^$9!#e(BGB18030
e$B$Oe(B
UTF-8 e$B$N%9!<%Q!<%;%C%H$G$9$+$i!"e(BGB18030 → UTF-8 → GB18030
e$B$G$O85$KLa$i$J$$%1!<%9$,B8:_$7$^$9!#e(B

e$B$=$&$9$k$H!"$3$&$$$&JQ49$r9T$&$N$Oe(B Windows e$B$@$1$K8BDj$9$kI,e(B
e$BMW$,M-$j$^$9!#$=$9$k$H<!$N$h$&$K$J$j$^$9!#e(B

% ./ruby -e ’
opt = /windows/ =~ RUBY_PLATFORM ? {:external_encoding=>“utf-16le”,
:internal_encoding=>“utf-8”} : {}
Dir.open(“.”, opt) {|d|
while n = d.read
p [File.size(n), n]
end
}’

e$B7k6I!“e(BFile.size e$B$O3N<B$K%U%!%$%k$rF1Dj$9$kI,MW$,$”$C$F!"$=$Ne(B
e$BE@$G$OJ8;z%3!<%I$NJQ49$O4pK\E*$K<YKb$G!"Lq2p<T$G$7$+M-$j$^$;e(B
e$B$s!#e(B

e$B$b$A$m$s!“$3$NLdBj$Oe(B File.size e$B$@$1$G$O$J$/$F!”%U%!%$%k$N<Be(B
e$BBN$K%"%/%;%9$9$k$9$Y$F$NA`:ne(B (stat, open, unlink, link, …)
e$B$GLdBj$K$J$j$^$9!#e(B

e$B$=$&$9$k$H!"$d$O$jJQ49$7$F$$$J$$@8$N%U%!%$%kL>$,I,MW$G!"e(B
Unix e$B$G$O%P%$%HNs$=$N$^$^$Ge(B locale e$B$Je(B encoding
e$B$,$D$$$?$b$N!"e(B
Windows e$B$G$Oe(B UTF-8 e$B$J$b$N$rJV$9%*%W%7%g%s$r2>$Ke(B
:native_filename=>true e$B$H$9$k$H!"0J2<$N$h$&$K=q$1$^$9!#e(B

% ruby -e ’
Dir.open(“.”, :native_filename=>true) {|d|
while n = d.read
p [File.size(n), n]
end
}’

e$B$3$3$G$O!“@8$N%U%!%$%kL>$re(B p e$B$GI=<($7$F$$$^$9$,!”$A$c$s$He(B
locale e$B$K=>$C$F%(%s%3!<%I$9$k$J$i!"0J2<$N$h$&$KJQ49$7$^$9!#e(B
(e$B$3$3$GJQ49$K<:GT$7$?$H$-$NBP=h$,I,MW$+$b$7$l$^$;$se(B)

e$B$7$+$7!“e(BFile.size e$B$KEO$9%U%!%$%kL>$OJQ49$7$^$;$s$7!”$7$F$O$$e(B
e$B$1$^$;$s!#e(B

% ruby -e ’
Dir.open(“.”, :native_filename=>true) {|d|
while n = d.read
p [File.size(n), n.encode(Encoding.locale_charmap)]
end
}’

e$B$^$?!"%U%!%$%kL>$rI8=`F~NO$K=P$9$N$G$J$/!“e(BGUI e$B$GI=<($9$k$N$Ge(B
e$B$”$l$P!“e(BGUI
e$B$N07$&%3!<%I$KJQ49$9$kI,MW$,$”$k$G$7$g$&!#$7$+$7!“e(B
e$B$d$O$j$=$N>l9g$G$be(B File.size e$B$KEO$9%U%!%$%kL>$OJQ49$7$^$;$se(B
e$B$7!”$7$F$O$$$1$^$;$s!#e(B

e$B$3$N$h$&$K!“7k6I!”%U%!%$%kL>$r3N<B$K07$&$N$KI,MW$J5!9=$O!"3Ne(B
e$B<B$K%U%!%$%k$rF1Dj$G$-$k%U%!%$%kL>$rF@$k$3$H$G!"J8;z%3!<%I$Ne(B
e$BJQ49$O<YKb$G$9!#e(B

e$BJQ49$OI=<($N:]$KI,MW$K$J$j$^$9$,!“BP>]$,%U%!%$%kL>$G$”$k0J>e!"e(B
e$B%U%!%$%k$,F1Dj$G$-$J$/$J$k$N$O$`$7$mLdBj$,Bg$-$$$H9M$($i$l$^e(B
e$B$9!#e(B

e$B$=$l$J$N$K!"$J$s$G$=$s$J5!9=$re(B Dir e$B$K$D$1$k$s$G$7$g$&e(B?

internal_encoding, external_encoding e$B$C$F!“$I$&$$$&%”%W%j%1!<e(B
e$B%7%g%s$GLr$KN)$D$s$G$7$g$&e(B?

e$BEv;~$O$"$^$jL@<(E*$Ke(B force_encoding / encode e$B$5$;$?$/$J$$$H$$$&<q;]$G$7$?!#e(B

locale e$B$K=>$C$F1?MQ$5$l$F$$$k%7%9%F%`$rA[Dj$9$kMQK!$J$ie(B
e$B8=>u$Ge(B force_encoding e$B$be(B encode e$B$bITMW$G$9!#e(B

e$B$=$&$G$J$$A[Dj$r$9$k$J$i!“e(Binternal_encoding,
external_encoding e$B$,Lr$KN)$D%”%W%j%1!<%7%g%s$C$F$I$&$$$&%1!<e(B
e$B%9$G$7$g$&e(B?

Windows e$B$Ge(B Unicode e$B$J%U%!%$%kL>$r07$&$H$-$@$H$7$F$b!“$=$N=qe(B
e$B$-J}$H$7$F!”%]!<%?%V%k$K$J$i$J$$=q$-J}$rDs0F$9$k$N$O$h$/$J$$e(B
e$B$s$8$c$J$$$G$7$g$&$+!#e(B

internal_encoding, external_encoding e$B$,Lr$KN)$D%"%W%j%1!<%7%ge(B
e$B%s$N6qBNE*$JNc$C$F$J$$$s$G$7$g$&$+e(B?

e$B7k6I$N$H$3$m!"%W%m%0%i%`$G4hD%$i$;$k$Y$-$+!"e(B
e$B@_Dj$N<jCJ$r$9$k$Y$-$+$H$$$&=j$J$N$G$9$+$M$'!#e(B

Dir e$B$K$h$kJQ49$O!"%W%m%0%i%`$rJQ$JJ}8~$K$,$s$P$i$;$k$N$G$O$Je(B
e$B$$$G$7$g$&$+!#e(B

Windows e$B$+$I$&$+$r>r7oH=CG$9$k$H$+!"5UJQ49$,I,MW$K$J$k$H$+!#e(B

e$B$D$^$k$H$3$m!"Nc30$,=P$?;~$N=hM}$NMxJX@-$+e(B

e$B5UJQ49$,2DG=$G$“$k$h$&$J>l9g$K$O!“JQ49$7$F$bLdBj$,$J$$$N$+$be(B
e$B$7$l$^$;$s!#$=$&$$$&0UL#$G!”$3$NLdBj$rJQ49$GNc30$,=P$?$H$-$Ne(B
e$BLdBj$H$$$&$H$i$($+$?$O$”$j$($k$G$7$g$&!#e(B

e$B$7$+$7!“;d$O!”$=$b$=$bJQ49$9$k$N$,LdBj$@$H$H$i$($F$$$^$9!#e(B

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

Windows e$B$Ge(B Unicode e$B$J%U%!%$%kL>$r07$&$H$-$@$H$7$F$b!"$=$N=qe(B
e$B$-J}$H$7$F!"%]!<%?%V%k$K$J$i$J$$=q$-J}$rDs0F$9$k$N$O$h$/$J$$e(B
e$B$s$8$c$J$$$G$7$g$&$+!#e(B

internal_encoding, external_encoding e$B$,Lr$KN)$D%"%W%j%1!<%7%ge(B
e$B%s$N6qBNE*$JNc$C$F$J$$$s$G$7$g$&$+e(B?

e$BA[Dj$H$7$F$O!"e(BUnix e$B7O$G%U%!%$%k%7%9%F%$N%(%s%3!<%G%#%s%0$,e(B locale e$B$H0[$J$k>l9g$G$9!#e(B e$B$3$N>l9g!"e(BUnix e$B7O$J$N$G%U%!%$%k%7%9%F%>e$N%Q%9J8;zNs$OJQ49$5$l$:!“e(B
e$B$=$N0lJ}$G%U%!%$%k%7%9%F%`$N%(%s%3!<%G%#%s%0$,%;%C%H$5$l$^$9!#e(B
e$B$3$Ne(B string e$B$r07$&e(B force_encoding
e$B$9$kI,MW$,$”$k$3$H$r7y$$$^$7$?!#e(B

file e$B$Ne(B open e$B$N>l9g!"e(B
UTF-8 e$B%m%1!<%k$K$Fe(B Shift_JIS e$B$N%F%-%9%H$rFI$`>l9g$K!"e(B
open(“sjis.txt”){|f| puts f.read.force_encoding(“UTF-8”) }
e$B$H$9$k$N$G$O$J$/!“e(B
open(“sjis.txt”, “r:sjis”){|f| puts f.read }
e$B$H$7$?J}$,%9%^!<%H$J$N$G$9$,!”$3$l$HF1MM$Ke(B

Shift_JIS e$B%m%1!<%k$K$Fe(B UTF-8 e$B$J%U%!%$%k%7%9%F%`$N>l9g!“e(B
opendir(”."){|dir| puts dir.read.force_encoding(“UTF-8”) }
e$B$h$j$be(B
opendir(".", :external_encoding=>“UTF-8”){|dir| puts dir.read }
e$B$H$7$?J}$,%9%^!<%H$G$"$m$&$H9M$($^$7$?!#e(B

e$B$^$!!"EDCf$5$s$N;XE&$G5$IU$$$?$N$G$9$,!"e(B
filesystem e$B$H0[$J$ke(B encoding e$B$r;}$C$F$$$k$,@5$7$$e(Bpath
e$B$Ne(B string e$B$r!"e(B
e$BB>$Ne(B FS e$B7O$Ne(B API e$B$K$D$C$3$s$@>l9g$OG:$^$7$/!"e(B
e$B0z?t$Ne(B string e$B$re(B filesystem encoding e$B$K<+F0JQ49!“e(B
e$B$^$?$Oe(B filesystem encoding
e$B$H0[$J$k>l9g$ONc30!”$J$s$F$3$H$r$9$k$H!"e(B
Unix e$B7O$G$O$3$N%1!<%9$GHa$7$$$3$H$K$J$j$^$9!#e(B

e$BK\Ev$Oe(B dir e$B$G$J$/!"$=$Ne(B filesystem e$B$Ke(B
external encoding e$B$r%;%C%H$7$J$$$H$$$1$J$$$s$@$m$&$J!#e(B

e$B$^$!!"$3$l$K4X$7$F$O$3$N<j$N<+F0JQ49$rD|$a$l$P$$$$$N$G$9$,!#e(B

Tanaka A. wrote:

Windows e$B$G$Oe(B UTF-8 e$B$J$b$N$rJV$9%*%W%7%g%s$r2>$Ke(B
:native_filename=>true e$B$H$9$k$H!"0J2<$N$h$&$K=q$1$^$9!#e(B

% ruby -e ’
Dir.open(".", :native_filename=>true) {|d|
while n = d.read
p [File.size(n), n]
end
}’

e$B$d$C$HEDCf$5$s$N0U?^$7$?LdBjE@$,M}2r$G$-$^$7$?!#e(B
e$B$4;XE&$N2]Bj$O6D$kDL$j$G!"3N$+$K2r7h:v$O!"e(B
e$B!VL5JQ49$N%Q%9$K3NEY$N9b$$%(%s%3!<%G%#%s%0$r$D$1$F$rJV$9e(B API
e$B$rMQ0U$9$k!We(B
e$B$,%Y%9%H$G$7$g$&!#e(B

e$B$3$N$h$&$K!“7k6I!”%U%!%$%kL>$r3N<B$K07$&$N$KI,MW$J5!9=$O!"3Ne(B
e$B<B$K%U%!%$%k$rF1Dj$G$-$k%U%!%$%kL>$rF@$k$3$H$G!"J8;z%3!<%I$Ne(B
e$BJQ49$O<YKb$G$9!#e(B

e$BEDCf$5$s$NG’<1$G$O!“e(B:external_encoding/:internal_encoding
e$B$O!“e(B
e$B%U%!%$%k%Q%9$NJQ49$N$?$a$N5!9=$G$”$k!”$H$J$C$F$$$k$h$&$K;W$$$^$9!#e(B

e$B$o$?$7$NG’<1$G$O0J2<$NDL$j$K$J$C$F$$$^$9!#e(B
:external_encoding :
e$B%U%!%$%k%7%9%F%$N%(%s%3!<%G%#%s%0$r6/@)E*$K;XDj$9$k5!9=e(B :internal_encoding : e$B<+F0JQ49$N$?$a$N5!9=e(B e$B$J$N$G!"$3$A$i$G!"e(B :external_encoding : e$B%7%9%F%%M%$%F%#%V$N%(%s%3!<%G%#%s%0$r;XDje(B
(e$B8=:_$O$J$$e(B)
:internal_encoding : e$B<+F0JQ49$5$;$J$$e(B
e$B$H;XDj$9$l$P!"e(B
e$B!VL5JQ49$N%Q%9$K3NEY$N9b$$%(%s%3!<%G%#%s%0$r$D$1$F$rJV$9e(B API
e$B$rMQ0U$9$k!We(B
e$B$O0l1~<B8=$G$-$^$9!#e(B

e$B$A$J$_$K!"e(BWindows e$B%U%!%$%k%Q%9$re(B FS
e$B$KEO$7$?>l9g$NF0:n$NM=Dj$r=q$$$F$*$/$H!"e(B
US-ASCIIe$B!"e(BASCII-8BIT e$B5Z$Se(B Unicode e$B7Oe(B -> UTF-16LE
e$B$K$7$Fe(B Unicode API e$B$KEO$9e(B
locale -> ANSI API e$B$KEO$9e(B or UTF-16LE e$B$KJQ49$7$F$+$ie(B Unicode
API e$B$KEO$9e(B
e$B$=$l0J30e(B -> UTF-16LEe$B$K<+F0JQ49$7$Fe(B Unicode API or e$BNc30e(B
or e$B$=$N$^$^e(B ANSI

e$BLdBj$O$=$l0J30$G!“e(B
e$B<+F0JQ49$9$k$He(B Microsoft CodePage
e$B0J30$+$iJQ49$9$k$H%^%C%T%s%0$N0c$$$G$O$^$k2DG=@-$,e(B
e$B9b$$$N$Ge(B MSCP e$B$G$J$$>l9g$+!”$^$?$Oe(B locale
e$B0J30$G$ONc30$r=P$7$?$$$N$G$9$,!"e(B
e$B$=$l$r$d$k$He(B Unix
e$B$N>l9g$GHa$7$$;W$$$r$9$k$N$GG:$^$7$/;W$C$F$$$k$H$3$m$G$9!#e(B

In article [email protected],
Tanaka A. [email protected] writes:

Shift_JIS e$B%m%1!<%k$K$Fe(B UTF-8 e$B$J%U%!%$%k%7%9%F%`$N>l9g!“e(B
opendir(”.“){|dir| puts dir.read.force_encoding(“UTF-8”) }
e$B$h$j$be(B
opendir(”.“, :external_encoding=>“UTF-8”){|dir| puts dir.read }
e$B$H$7$?J}$,%9%^!<%H$G$”$m$&$H9M$($^$7$?!#e(B

e$B>e5-$NNc$G$Oe(B puts e$B$7$+$7$F$$$^$;$s!#e(B
e$B$=$N$h$&$KI=<($9$k$@$1$G$"$l$P;HMQ$G$-$^$9$,!"e(Bopen e$B$J$I$NA`e(B
e$B:n$O$G$-$J$$$o$1$G$9$h$M!#e(B

e$B$*$C$H!"e(B:external_encoding e$B$@$1$N;XDj$J$i%P%$%HNs$OJQ49$5$le(B
e$B$J$$$N$Ge(B open e$B$H$+$b$G$-$^$9$M!#e(B

:internal_encoding e$B$r;XDj$9$k$H$@$a$G$9$,!#e(B

Dir e$B$Ne(B :external_encoding e$B$He(B :internal_encoding e$B$O:o=|$7$^$;e(B
e$B$s$+e(B?

:internal_encoding e$B$K$D$$$F$O!":o=|$7$?$[$&$,$$$$$H$$$&$N$Oe(B
e$BJQ$o$j$^$;$s!#e(B

e$B$H$3$m$G!"e(BWindows e$B$Ge(B :external_encoding e$B$Ke(B Unicode
e$B$G$be(B
locale e$B$G$b$J$$e(B encoding e$B$r;XDj$7$?$i$I$&$J$k$s$G$9$,e(B?

In article [email protected],
“NARUSE, Yui” [email protected] writes:

e$BA[Dj$H$7$F$O!"e(BUnix e$B7O$G%U%!%$%k%7%9%F%`$N%(%s%3!<%G%#%s%0$,e(B
locale e$B$H0[$J$k>l9g$G$9!#e(B
e$B$3$N>l9g!"e(BUnix e$B7O$J$N$G%U%!%$%k%7%9%F%`>e$N%Q%9J8;zNs$OJQ49$5$l$:!“e(B
e$B$=$N0lJ}$G%U%!%$%k%7%9%F%`$N%(%s%3!<%G%#%s%0$,%;%C%H$5$l$^$9!#e(B
e$B$3$Ne(B string e$B$r07$&e(B force_encoding e$B$9$kI,MW$,$”$k$3$H$r7y$$$^$7$?!#e(B

e$B$J$k$[$I!#e(B

opendir(“.”, :external_encoding=>“UTF-8”){|dir| puts dir.read }
e$B$H$7$?J}$,%9%^!<%H$G$"$m$&$H9M$($^$7$?!#e(B

e$B>e5-$NNc$G$Oe(B puts e$B$7$+$7$F$$$^$;$s!#e(B
e$B$=$N$h$&$KI=<($9$k$@$1$G$"$l$P;HMQ$G$-$^$9$,!"e(Bopen e$B$J$I$NA`e(B
e$B:n$O$G$-$J$$$o$1$G$9$h$M!#e(B

e$BI=<($7$+9T$o$J$$%“%W%j%1!<%7%g%s$C$F$I$N$/$i$$$”$k$s$G$7$g$&$+e(B?

Dir e$B$rI=<(@lMQ$K$7$F$7$^$&%*%W%7%g%s$O!"E,@Z$H$O;W$($^$;$s!#e(B

Dir e$B$Ne(B :external_encoding e$B$He(B :internal_encoding
e$B$O:o=|$7$^$;e(B
e$B$s$+e(B?

e$B$^$!!"EDCf$5$s$N;XE&$G5$IU$$$?$N$G$9$,!"e(B
filesystem e$B$H0[$J$ke(B encoding e$B$r;}$C$F$$$k$,@5$7$$e(Bpath e$B$Ne(B string e$B$r!"e(B
e$BB>$Ne(B FS e$B7O$Ne(B API e$B$K$D$C$3$s$@>l9g$OG:$^$7$/!"e(B
e$B0z?t$Ne(B string e$B$re(B filesystem encoding e$B$K<+F0JQ49!“e(B
e$B$^$?$Oe(B filesystem encoding e$B$H0[$J$k>l9g$ONc30!”$J$s$F$3$H$r$9$k$H!"e(B
Unix e$B7O$G$O$3$N%1!<%9$GHa$7$$$3$H$K$J$j$^$9!#e(B

Unix e$B$N%U%!%$%kL>$OJ8;zNs$G$J$/%P%$%HNs$J$N$G!"J8;zNs$@$H;W$Ce(B
e$B$F07$($PL5MQ$KLdBj$r8F$S9~$_$^$9$M!#e(B

e$BK\Ev$Oe(B dir e$B$G$J$/!"$=$Ne(B filesystem e$B$Ke(B
external encoding e$B$r%;%C%H$7$J$$$H$$$1$J$$$s$@$m$&$J!#e(B

e$B$3$l$O0U?^$,$h$/$o$+$j$^$;$s!#e(B

e$B$d$C$HEDCf$5$s$N0U?^$7$?LdBjE@$,M}2r$G$-$^$7$?!#e(B
e$B$4;XE&$N2]Bj$O6D$kDL$j$G!"3N$+$K2r7h:v$O!"e(B
e$B!VL5JQ49$N%Q%9$K3NEY$N9b$$%(%s%3!<%G%#%s%0$r$D$1$F$rJV$9e(B API e$B$rMQ0U$9$k!We(B
e$B$,%Y%9%H$G$7$g$&!#e(B

e$B$($'!#e(B

e$BEDCf$5$s$NG’<1$G$O!“e(B:external_encoding/:internal_encoding e$B$O!“e(B
e$B%U%!%$%k%Q%9$NJQ49$N$?$a$N5!9=$G$”$k!”$H$J$C$F$$$k$h$&$K;W$$$^$9!#e(B

e$B$O$$!#8=;~E@$N%3!<%I$rFI$s$@7k2L!"$=$N$h$&$K;W$$$^$7$?!#e(B

e$B$o$?$7$NG’<1$G$O0J2<$NDL$j$K$J$C$F$$$^$9!#e(B
:external_encoding : e$B%U%!%$%k%7%9%F%$N%(%s%3!<%G%#%s%0$r6/@)E*$K;XDj$9$k5!9=e(B :internal_encoding : e$B<+F0JQ49$N$?$a$N5!9=e(B e$B$J$N$G!"$3$A$i$G!"e(B :external_encoding : e$B%7%9%F%%M%$%F%#%V$N%(%s%3!<%G%#%s%0$r;XDje(B (e$B8=:_$O$J$$e(B)
:internal_encoding : e$B<+F0JQ49$5$;$J$$e(B
e$B$H;XDj$9$l$P!"e(B
e$B!VL5JQ49$N%Q%9$K3NEY$N9b$$%(%s%3!<%G%#%s%0$r$D$1$F$rJV$9e(B API e$B$rMQ0U$9$k!We(B
e$B$O0l1~<B8=$G$-$^$9!#e(B

e$B$d$j$?$$$3$H$KBP$7$F$=$l$O1*1s$G$O$"$j$^$;$s$+e(B?

e$B$=$l$K!";XDj$K<:GT$9$k$He(B Dir e$B$OI=<(@lMQ$K$J$C$F$7$^$&$o$1$Ge(B
e$B$9$h$M!#$=$s$J2DG=@-$r$3$l$_$h$,$7$KDs6!$9$k$N$ONI$/$J$$$N$Ge(B
e$B$O$J$$$G$7$g$&$+!#e(B

e$B$A$J$_$K!"e(BWindows e$B%U%!%$%k%Q%9$re(B FS e$B$KEO$7$?>l9g$NF0:n$NM=Dj$r=q$$$F$*$/$H!"e(B
US-ASCIIe$B!"e(BASCII-8BIT e$B5Z$Se(B Unicode e$B7Oe(B → UTF-16LE e$B$K$7$Fe(B Unicode API e$B$KEO$9e(B
locale → ANSI API e$B$KEO$9e(B or UTF-16LE e$B$KJQ49$7$F$+$ie(B Unicode API e$B$KEO$9e(B
e$B$=$l0J30e(B → UTF-16LEe$B$K<+F0JQ49$7$Fe(B Unicode API or e$BNc30e(B or e$B$=$N$^$^e(B ANSI

e$BLdBj$O$=$l0J30$G!“e(B
e$B<+F0JQ49$9$k$He(B Microsoft CodePage e$B0J30$+$iJQ49$9$k$H%^%C%T%s%0$N0c$$$G$O$^$k2DG=@-$,e(B
e$B9b$$$N$Ge(B MSCP e$B$G$J$$>l9g$+!”$^$?$Oe(B locale e$B0J30$G$ONc30$r=P$7$?$$$N$G$9$,!"e(B
e$B$=$l$r$d$k$He(B Unix e$B$N>l9g$GHa$7$$;W$$$r$9$k$N$GG:$^$7$/;W$C$F$$$k$H$3$m$G$9!#e(B

Unix e$B$N%U%!%$%kL>$O%P%$%HNs$J$N$G!"e(Bstring e$B$N%(%s%3!<%G%#%s%0e(B
e$B$OL5;k$7$F%P%$%HNs$r$=$N$^$^;H$&$Y$-$G$9!#%(%s%3!<%G%#%s%0$Ke(B
e$B$h$C$FNc30$K$9$k$N$OH?BP$G$9!#e(B

Windows e$B$N%U%!%$%kL>$OJ8;zNs$@$H;W$&$N$G!"e(Blocale e$B0J30$OA4Ite(B
UTF-16LE e$B$KJQ49$7$F$7$^$($P$$$$$N$G$O$J$$$+$H;W$C$F$$$^$9!#e(B

In article [email protected],
“NARUSE, Yui” [email protected] writes:

:external_encoding/:inernal_encoding e$BJ}<0$@$H!“e(BWindows e$B4D6-MQ$Ke(B
:internal_encoding e$B$,I,MW$G$9!#e(B
e$B$D$^$j!”%G%U%)%k%H$Ge(B locale e$B$,F~$C$F$$$F!"$3$3$G<+F0JQ49$r$7$F$$$^$9!#e(B

e$B$`$7$m!":G$b;H$o$l$k$N$O$3$A$i$J$N$+$J!#e(B

e$B$h$/$o$+$i$+$C$?$N$G$9$,!"6qBNE*$Ke(B :internal_encoding e$B$O$I$&e(B
e$B;H$&$N$G$9$+e(B?

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

Tanaka A. wrote:

e$B;H$&$N$G$9$+e(B?
Windows e$B$Ge(B W e$B7Oe(B API e$B$,;H$o$l$k$N$rA0Ds$H$7$Fe(B
(e$B:#$O$^$@e(B A e$B7Oe(B)e$B!"e(B

Dir.foreach(".", :internal_encoding => “CP51932”) do |fn|
p [fn, File.size(fn)] # Windows e$B$J$N$G%Q%9<+F0JQ49e(B
end

e$B$H$+$G$7$g$&$+!#e(B

Tanaka A. wrote:

opendir(".", :external_encoding=>“UTF-8”){|dir| puts dir.read }
Dir e$B$Ne(B :external_encoding e$B$He(B :internal_encoding e$B$O:o=|$7$^$;e(B
e$B$s$+e(B?

[ruby-dev:35644] e$B$NDL$j!"e(B:external_encoding e$B$N$_$@$He(B
force_encoding e$B$K$J$j$^$9!#e(B

:external_encoding/:inernal_encoding e$BJ}<0$@$H!“e(BWindows
e$B4D6-MQ$Ke(B
:internal_encoding e$B$,I,MW$G$9!#e(B
e$B$D$^$j!”%G%U%)%k%H$Ge(B locale
e$B$,F~$C$F$$$F!"$3$3$G<+F0JQ49$r$7$F$$$^$9!#e(B

e$B$`$7$m!":G$b;H$o$l$k$N$O$3$A$i$J$N$+$J!#e(B

e$B$^$!!"EDCf$5$s$N;XE&$G5$IU$$$?$N$G$9$,!"e(B
filesystem e$B$H0[$J$ke(B encoding e$B$r;}$C$F$$$k$,@5$7$$e(Bpath e$B$Ne(B string e$B$r!"e(B
e$BB>$Ne(B FS e$B7O$Ne(B API e$B$K$D$C$3$s$@>l9g$OG:$^$7$/!"e(B
e$B0z?t$Ne(B string e$B$re(B filesystem encoding e$B$K<+F0JQ49!“e(B
e$B$^$?$Oe(B filesystem encoding e$B$H0[$J$k>l9g$ONc30!”$J$s$F$3$H$r$9$k$H!"e(B
Unix e$B7O$G$O$3$N%1!<%9$GHa$7$$$3$H$K$J$j$^$9!#e(B

Unix e$B$N%U%!%$%kL>$OJ8;zNs$G$J$/%P%$%HNs$J$N$G!"J8;zNs$@$H;W$Ce(B
e$B$F07$($PL5MQ$KLdBj$r8F$S9~$_$^$9$M!#e(B

e$B$"$!!"$J$k$[$I!#e(B

e$B$=$l$K!";XDj$K<:GT$9$k$He(B Dir e$B$OI=<(@lMQ$K$J$C$F$7$^$&$o$1$Ge(B
e$B$9$h$M!#$=$s$J2DG=@-$r$3$l$_$h$,$7$KDs6!$9$k$N$ONI$/$J$$$N$Ge(B
e$B$O$J$$$G$7$g$&$+!#e(B

e$B$3$l8+$h$,$7$K$J$i$J$$DxEY$K$O;H$$$E$i$/$7$?$D$b$j$G$9!"e(B17e$BJ8;z$G$9$7!#e(B
e$B4pK\E*$K$O;XDj$7$J$/$F$$$$$O$:$G$9$7!#e(B
(Unix e$B$de(B Mac OS X e$B$G$O:G=i$+$i@8e(B+localee$B$@$+$ie(B)

Unix e$B$N%U%!%$%kL>$O%P%$%HNs$J$N$G!"e(Bstring e$B$N%(%s%3!<%G%#%s%0e(B
e$B$OL5;k$7$F%P%$%HNs$r$=$N$^$^;H$&$Y$-$G$9!#%(%s%3!<%G%#%s%0$Ke(B
e$B$h$C$FNc30$K$9$k$N$OH?BP$G$9!#e(B

Windows e$B$N%U%!%$%kL>$OJ8;zNs$@$H;W$&$N$G!"e(Blocale e$B0J30$OA4Ite(B
UTF-16LE e$B$KJQ49$7$F$7$^$($P$$$$$N$G$O$J$$$+$H;W$C$F$$$^$9!#e(B

e$B$J$k$[$I!"$=$N6hJL$OL@2w$G$9$M!#e(B
e$B$3$A$i$O$=$l$G;?@.$G$9!#e(B

e$B$H$3$m$G!"e(BWindows e$B$Ge(B :external_encoding e$B$Ke(B Unicode e$B$G$be(B
locale e$B$G$b$J$$e(B encoding e$B$r;XDj$7$?$i$I$&$J$k$s$G$9$,e(B?

Windows e$B$G$Oe(B :external_encoding e$B$Oe(B Unicode
e$B7O$N$_$G$9$+$M!#e(B
e$B!Ve(BWindows e$B$N%U%!%$%kL>$OJ8;zNs!W$H$$$&$N$O!"e(BUnicode
e$BJ8;z$N;v$G$7$g$&$+$i!#e(B

Unicode e$B0J30$Ne(B :external_encoding e$B$@$HNc30$G$$$$$N$+$J!#e(B
Windows
e$B$N%U%!%$%kL>$,%P%$%HNs$K$J$k%1!<%9$,$b$7B8:_$9$k$J$i$PI,MW$J$N$G$7$g$&$,!"e(B
e$B0JA0$Ne(B samba e$B$NOCEy$N46$8$G$OI,MW$J$5$=$&$G$7$?$7!#e(B

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

Tanaka A. wrote:

e$B$U$`!“e(BCP51932 e$B$G$9$+!#;HMQIQEY$,Dc$=$&$G$9$M!#e(B
e$B$b$C$HIaDL$N?M$,;H$$$=$&$JNc$C$F$”$j$^$9$+e(B?

Windows e$B>e$G$Ne(B Dir.open e$B$N%G%U%)%k%H$O!“e(B
:external_encoding = UTF-8
:internal_encoding = CP932
e$B$J$N$G!”$3$A$i$,:G$b;HMQIQEY$N9b$$Nc$G$7$g$&$+!#e(B
e$B%G%U%)%k%H$N@_Dj$r!V;H$&!W$H8@$&$N$+$I$&$+$OHyL/$J$H$3$m$G$9$,!#e(B

e$B$C$F!"$b$7$+$7$F!"EDCf$5$s$NA[Dj$@$H!"e(BWindows e$B$G$O!"e(B
:external_encoding e$B$Ke(B locale
e$B$r;XDj2DG=$C$F$3$H$K$J$C$F$^$9!)e(B
:external_encoding e$B$NItJ,$G$O7gMn$NH/@8$9$kJQ49$Oe(B
e$B9T$o$J$$$D$b$j$@$C$?$N$G$9$,!"e(B

e$B$H=q$-$^$7$?$,!“e(B:internal_encoding e$B$r;H$&$H!”%U%!%$%k$rF1Dje(B
e$B$G$-$J$/$J$j$^$9!#$3$l$O5v$7Fq$$@-<A$G$9!#e(B

e$B%U%!%$%k$N%Q%9$,%P%$%HNs$G$"$ke(B Unix e$B$G$O!“e(B
e$B$=$N$h$&$JA`:n$O6KNO;H$$$E$i$/$9$k$Y$-!”$H$$$&<gD%$G$9$h$M!#e(B
e$BM}2r$O$G$-$^$9!#e(B

String#encode e$B$G9T$&$H$$$&$N$,$$$$$s$8$c$J$$$G$7$g$&$+!#e(B
e$B;n9T:x8m$7$?$$$H$-$Oe(B :internal_encoding
e$B$r;H$o$J$1$l$P$$$$$G$9$h$M!#e(B
e$B$=$7$F!"$3$3$G;H$o$:$7$F$I$3$G;H$&$s$@$H$$$&<ALd$N2sEz$O!“e(B
e$B%G%U%)%k%HF0:n$G;H$&!”$K$J$j$^$9!#e(B

e$B$3$N$"$?$j$NLdBj$O$b$H$h$je(B Windows e$B$Ne(B A e$B7Oe(B API
e$B$,;}$C$F$$$kLdBj$G$9$M!#e(B
e$B$^$?!"e(BWindows e$B$K$*$$$F$O%G%U%)%k%H$G$Oe(B locale
e$B$NJ8;zNs$rJV$7B3$1$J$$$He(B
e$B$$$1$J$$$G$7$g$&$+$i!"F($l$i$l$J$$LdBj$H$b$$$($^$9!#e(B

e$B$"$H!“JQ49$K<:GT$7$?$H$-$K%U%!%$%kL>$,<:$o$l$k!”$H$$$&E@$b$"e(B
e$B$j$^$9!#e(BDir#read e$BFb$G!“e(Breaddir(3) [email protected]$7$?8e$KJQ49$r9T$&$?e(B
e$B$a!”$=$3$GNc30$,5/$-$l$Pe(B readdir e$B$,JV$7$?%U%!%$%kL>$,<:$o$le(B
e$B$^$9!#e(B

e$B$3$NJU$Oe(B transcode e$B$N<:GT;~$N%*%W%7%g%s3HD%$GB?>/$O!#e(B

e$B$=$3$b:o=|$7$F$"$j$^$9!#e(B
e$B$3$N%Q%C%A$@$H!"e(Breaddir e$B$,2?$rJV$9$+$K0MB8$7$^$9$,!"e(B
Windows e$B4D6-$K$*$$$Fe(B UTF-16LE e$B$+e(B locale
e$B$+$I$A$i$+$7$+F@$i$l$^$;$s$h$M!#e(B

e$B$^$H$a$k$H!“0J2<$NF0:n$,$G$-$kI,MW$,$”$k!<$G$9$+$M!#e(B

== e$B%G%U%)%k%He(B
Windows: UTF-16LE -> locale e$B<+F0JQ49e(B
Unix: locale

== e$B@8e(B
Windows: UTF-8
Unix: locale

== e$B6/@);XDje(B
Unix: e$BG$0U$Ne(B encoding e$B$Ke(B force_encoding

In article [email protected],
“NARUSE, Yui” [email protected] writes:

Windows e$B$Ge(B W e$B7Oe(B API e$B$,;H$o$l$k$N$rA0Ds$H$7$Fe(B (e$B:#$O$^$@e(B A e$B7Oe(B)e$B!"e(B

Dir.foreach(“.”, :internal_encoding => “CP51932”) do |fn|
p [fn, File.size(fn)] # Windows e$B$J$N$G%Q%9<+F0JQ49e(B
end

e$B$H$+$G$7$g$&$+!#e(B

e$B$U$`!“e(BCP51932 e$B$G$9$+!#;HMQIQEY$,Dc$=$&$G$9$M!#e(B
e$B$b$C$HIaDL$N?M$,;H$$$=$&$JNc$C$F$”$j$^$9$+e(B?

e$B$7$+$7!"$d$O$je(B :internal_encoding e$B$r:o=|$7$?$[$&$,$$$$$H;W$$e(B
e$B$^$9!#e(B

e$B$^$:!“e(Bunix e$B$Ge(B :internal_encoding
e$B$r;H$C$FJQ49$9$k$H!”%U%!%$e(B
e$B%kL>$H$7$F$N%P%$%HNs$,2u$l$F!"e(Bopen e$BEy$NA`:n$,=PMh$J$/$J$j$^e(B
e$B$9!#0JA0!"e(B[ruby-dev:34933] e$B$Ge(B

| e$B%U%!%$%kL>$G0lHV=EMW$J$N$O!"%U%!%$%k$rF1Dj$G$-$k$H$$$&@-<A$Ge(B
| e$B$O$J$$$G$7$g$&$+!#%U%!%$%kL>$rFI$a$k$H$$$&$N$O$=$N<!$K$/$k@-e(B
| e$B<A$@$H;W$$$^$9!#e(B

e$B$H=q$-$^$7$?$,!“e(B:internal_encoding e$B$r;H$&$H!”%U%!%$%k$rF1Dje(B
e$B$G$-$J$/$J$j$^$9!#$3$l$O5v$7Fq$$@-<A$G$9!#e(B

e$B$^$?e(B windows
e$B$G$b!“;XDj$9$k%(%s%3!<%G%#%s%0$K$h$C$FLdBj$,$”$Ce(B
e$B$?$j$J$+$C$?$j$9$k$H$$$&$3$H$,$“$j$^$9!#@8$N%U%!%$%kL>$H;XDje(B
e$B$7$?%(%s%3!<%G%#%s%0$H$NJQ49$Ge(B round trip e$B$9$k$+$I$&$+$,LdBje(B
e$B$G$9$,!”$3$l$OCN$C$F$$$J$$$HH=CG$,:$Fq$G$9!#$7$+$b!"CN$i$J$$e(B
e$B$R$H$,;n9T:x8m$7$FD4$Y$F$_$h$&$H;W$C$F$b!"e(B:internal_encoding
e$B$r;H$&$H!“JQ4985$NJ8;zNs$r3NG’$G$-$^$;$s$+$i!”;n9T:x8m$9$k$3e(B
e$B$H<+BN$,:$Fq$G$9!#e(B

e$B$"$H!“JQ49$K<:GT$7$?$H$-$K%U%!%$%kL>$,<:$o$l$k!”$H$$$&E@$b$"e(B
e$B$j$^$9!#e(BDir#read e$BFb$G!“e(Breaddir(3)
[email protected]$7$?8e$KJQ49$r9T$&$?e(B
e$B$a!”$=$3$GNc30$,5/$-$l$Pe(B readdir e$B$,JV$7$?%U%!%$%kL>$,<:$o$le(B
e$B$^$9!#e(B

e$B$3$N$h$&$JLdBj$r9M$($k$He(B :internal_encoding e$B$KAjEv$9$k$3$H$re(B
e$B$d$j$?$1$l$P!"e(BDir e$B<+BN$8$c$J$/$F!"e(BDir e$B$r;H$&B&$,e(B
String#encode e$B$G9T$&$H$$$&$N$,$$$$$s$8$c$J$$$G$7$g$&$+!#e(B

e$B$D$^$j!"e(B
Dir.open(dir, :internal_encoding=>enc) {|d|
d.read
}
e$B$NBe$o$j$K!“e(B
Dir.open(dir) {|d|
d.read.encode(enc)
}
e$B$H$9$k!”$H$$$&$o$1$G$9!#e(B

e$B$3$&$9$l$P!"8F$S=P$7$?B&$O!"JQ4985$NJ8;zNs$rCN$k$3$H$,$G$-!"e(B
e$BJQ49$G2?$,5/$3$k$N$+$rD4$Y$k$3$H$,=PMh$^$9!#$^$?!“JQ49$K32$,e(B
e$B$”$k$3$H$rCN$C$F!"JQ49$;$:$K%U%!%$%kL>$r;H$&$h$&$K$J$l$P!"e(B
unix e$B$G$be(B windows e$B$G$bF0:n$9$k%W%m%0%i%`$,=q$1$k$h$&$K$J$j$^e(B
e$B$9!#e(B

e$B$H$$$&$o$1$G!"%Q%C%A$r=q$$$F$_$^$7$?!#e(B

e$B$J$*!“e(BDir.open e$B$N$H$3$m$Ge(B (unix e$B>e$G$be(B)
e$B%Q%9$rJQ49$9$k$3$H$,e(B
e$B$”$C$F!“e(BDir.open e$B=PMh$k$Y$-$b$N$,=PMh$J$$$3$H$,$”$C$?$N$G!“e(B
e$B$=$3$b:o=|$7$F$”$j$^$9!#e(B

% svn diff --diff-cmd diff -x ‘-u -p’
Index: dir.c

— dir.c (revision 18220)
+++ dir.c (working copy)
@@ -291,7 +291,6 @@ VALUE rb_cDir;
struct dir_data {
DIR *dir;
char *path;

  • rb_encoding *intenc;
    rb_encoding *extenc;
    };

@@ -315,7 +314,6 @@ dir_s_alloc(VALUE klass)

 dirp->dir = NULL;
 dirp->path = NULL;
  • dirp->intenc = NULL;
    dirp->extenc = NULL;

    return obj;
    @@ -332,66 +330,37 @@ dir_initialize(int argc, VALUE *argv, VA
    {
    struct dir_data *dp;
    static rb_encoding *fs_encoding;

  • rb_encoding *intencoding, *extencoding;

  • rb_encoding *extencoding;
    VALUE dirname, opt;
  • static VALUE sym_intenc, sym_extenc;
  • static VALUE sym_extenc;
  • if (!sym_intenc) {
  • sym_intenc = ID2SYM(rb_intern(“internal_encoding”));
  • if (!sym_extenc) {
    sym_extenc = ID2SYM(rb_intern(“external_encoding”));
    fs_encoding = rb_filesystem_encoding();
    }
  • intencoding = NULL;
    extencoding = fs_encoding;
    rb_scan_args(argc, argv, “11”, &dirname, &opt);

    if (!NIL_P(opt)) {

  •    VALUE v, extenc=Qnil, intenc=Qnil;
    
  •    VALUE v, extenc=Qnil;
       opt = rb_convert_type(opt, T_HASH, "Hash", "to_hash");
    
  •    v = rb_hash_aref(opt, sym_intenc);
    
  •    if (!NIL_P(v)) intenc = v;
       v = rb_hash_aref(opt, sym_extenc);
       if (!NIL_P(v)) extenc = v;
    

    if (!NIL_P(extenc)) {
    extencoding = rb_to_encoding(extenc);

  •  if (!NIL_P(intenc)) {
    
  • intencoding = rb_to_encoding(intenc);

  • if (extencoding == intencoding) {

  •    rb_warn("Ignoring internal encoding '%s': it is identical to 
    

external encoding ‘%s’",

  •      RSTRING_PTR(rb_inspect(intenc)),
    
  •      RSTRING_PTR(rb_inspect(extenc)));
    
  •    intencoding = NULL;
    
  • }
  •  }
    
  • }
  • else if (!NIL_P(intenc)) {
  •  rb_raise(rb_eArgError, "External encoding must be specified when 
    

internal encoding is given");
}
}

 FilePathValue(dirname);
  • {
  • rb_encoding *dirname_encoding = rb_enc_get(dirname);
  • if (rb_usascii_encoding() != dirname_encoding
  •  && rb_ascii8bit_encoding() != dirname_encoding
    

-#if defined APPLE

  •  && rb_utf8_encoding() != dirname_encoding
    

-#endif

  •  && extencoding != dirname_encoding) {
    
  •  if (!intencoding) intencoding = dirname_encoding;
    
  •  dirname = rb_str_transcode(dirname, 
    

rb_enc_from_encoding(extencoding));

  • }

  • }

    Data_Get_Struct(dir, struct dir_data, dp);
    if (dp->dir) closedir(dp->dir);
    if (dp->path) xfree(dp->path);
    dp->dir = NULL;
    dp->path = NULL;

  • dp->intenc = intencoding;
    dp->extenc = extencoding;
    dp->dir = opendir(RSTRING_PTR(dirname));
    if (dp->dir == NULL) {
    @@ -457,9 +426,6 @@ static VALUE
    dir_enc_str(VALUE str, struct dir_data *dirp)
    {
    rb_enc_associate(str, dirp->extenc);

  • if (dirp->intenc) {

  •    str = rb_str_transcode(str, 
    

rb_enc_from_encoding(dirp->intenc));

  • }
    return str;
    }

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

Tanaka A. wrote:

e$B%G%U%)%k%HF0:n$NFbIt$G;H$&$H$$$&$N$O!"%f!<%6$,;XDj2DG=$J%*%We(B
e$B%7%g%s$NB8:_0U5A$K$O$J$j$^$;$s!#e(B

e$B$U!<$`!#e(B

Windows e$B$Ne(B Unicode e$B%U%!%$%kL>$O8=:_07$o$l$F$$$^$;$s$N$G!"e(B
locale e$B$N>l9g$7$+07$C$F$$$^$;$s!#e(BUnicode e$B%U%!%$%kL>$N<BAu$Oe(B
e$B8e$NOC$G$9!#e(B

e$B>e$K2C$($F$3$NN)>l$@$H3N$+$K8=>ue(B :internal_encoding
e$B$OI,?$H$O$$$$$E$i$$$G$9$M!#e(B

Windows e$B$Ne(B Unicode
e$B%U%!%$%kL>$,F~$k$^$G$K$b$&$A$g$C$H9M$($F$*$-$^$9$N$G!“e(B
e$B$H$j$”$($:e(B [ruby-dev:35661]
e$B$N%Q%C%A$rEv$F$F$7$^$C$F$/$@$5$$$^$;$s$+!#e(B

e$BEvLLe(B Wndows e$B$Ge(B :enternal_encoding
e$B$r;XDj$7$h$&$H$7$?$iNc30$re(B
e$BEj$2$5$;$?$$$G$9$,!"$3$l$O8e$G$d$C$F$*$-$^$9!#e(B

e$B$3$s$P$s$Oe(B sheepman e$B$G$9!#e(B

On Sat, 26 Jul 2008 17:49:49 +0900
Tanaka A. [email protected] wrote:

e$B$H$$$&$o$1$G!"%Q%C%A$r=q$$$F$_$^$7$?!#e(B

external_encoding e$B$H$$$&L>A0$r$d$a$F!"e(Bfs_encoding e$B$J$I$Ke(B
e$BJQ$($k$H$$$&$N$O$I$&$G$7$g$&$+!#e(Bexternal_encoding
e$B$H$$$&L>A0$J$N$Ke(B
e$B$=$N%G%U%)%k%HCM$,e(B Encoding.default_external
e$B$H$O$^$C$?$/4X78$J$$e(B
e$B$H$$$&$N$O:.Mp$N85$@$H;W$$$^$9!#e(B

In article [email protected],
“NARUSE, Yui” [email protected] writes:

Windows e$B>e$G$Ne(B Dir.open e$B$N%G%U%)%k%H$O!“e(B
:external_encoding = UTF-8
:internal_encoding = CP932
e$B$J$N$G!”$3$A$i$,:G$b;HMQIQEY$N9b$$Nc$G$7$g$&$+!#e(B
e$B%G%U%)%k%H$N@_Dj$r!V;H$&!W$H8@$&$N$+$I$&$+$OHyL/$J$H$3$m$G$9$,!#e(B

e$B%G%U%)%k%H$N@_Dj$O!V;H$&!W$H$O$$$($J$$$G$7$g$&!#e(B

e$BC1$K$=$&$$$&JQ49$,%O!<%I%3!<%I$5$l$F$$$F!"%G%U%)%k%H$G$=$NJQe(B
e$B49$,F0$/$H$7$F$bLdBj$J$$$N$G!"e(B:internal_encoding e$B$H$$$&%*%We(B
e$B%7%g%s$NB8:_0U5A$K$O$J$j$^$;$s!#e(B

e$B$"$H!"e(BDir.open e$B$,%G%U%)%k%H$Ge(B Windows e$B$Ne(B Unicode
e$B$Je(B API e$B$re(B
(e$B%3!<%IJQ49$7$Fe(B) e$B;H$&$N$+!"e(Blocale e$B$Je(B API
e$B$r;H$&$N$+$O$h$/$oe(B
e$B$+$C$F$$$^$;$s$,!"8e<T$J$iJQ49$OITMW$G$7$g$&!#e(B

e$B$C$F!"$b$7$+$7$F!"EDCf$5$s$NA[Dj$@$H!"e(BWindows e$B$G$O!"e(B
:external_encoding e$B$Ke(B locale e$B$r;XDj2DG=$C$F$3$H$K$J$C$F$^$9!)e(B
:external_encoding e$B$NItJ,$G$O7gMn$NH/@8$9$kJQ49$Oe(B
e$B9T$o$J$$$D$b$j$@$C$?$N$G$9$,!"e(B

e$B$$$(!#e(B[ruby-dev:35644] e$B$G?R$M$Fe(B [ruby-dev:35652] e$B$Ge(B

| Windows e$B$G$Oe(B :external_encoding e$B$Oe(B Unicode e$B7O$N$_$G$9$+$M!#e(B

e$B$HEz$($F$$$?$@$$$?$N$G!"$?$H$($Pe(B UTF-8, UTF-16LE e$B$J$I$O;XDje(B
e$B2DG=$@$,!"e(BEUC-JP e$B$J$I$O;XDj$G$-$J$$$HA[Dj$7$F$$$^$9!#e(B

e$B;n9T:x8m$7$?$$$H$-$Oe(B :internal_encoding e$B$r;H$o$J$1$l$P$$$$$G$9$h$M!#e(B
e$B$=$7$F!"$3$3$G;H$o$:$7$F$I$3$G;H$&$s$@$H$$$&<ALd$N2sEz$O!“e(B
e$B%G%U%)%k%HF0:n$G;H$&!”$K$J$j$^$9!#e(B

e$B%G%U%)%k%HF0:n$NFbIt$G;H$&$H$$$&$N$O!"%f!<%6$,;XDj2DG=$J%*%We(B
e$B%7%g%s$NB8:_0U5A$K$O$J$j$^$;$s!#e(B

e$B$3$N$"$?$j$NLdBj$O$b$H$h$je(B Windows e$B$Ne(B A e$B7Oe(B API e$B$,;}$C$F$$$kLdBj$G$9$M!#e(B
e$B$^$?!"e(BWindows e$B$K$*$$$F$O%G%U%)%k%H$G$Oe(B locale e$B$NJ8;zNs$rJV$7B3$1$J$$$He(B
e$B$$$1$J$$$G$7$g$&$+$i!"F($l$i$l$J$$LdBj$H$b$$$($^$9!#e(B

e$B%U%!%$%kL>$,J8;zNs$G!"%3!<%IJQ49$r9T$&8B$j!"F($l$i$l$J$$$N$Oe(B
e$B$=$&;W$$$^$9!#e(B

e$B$7$+$7!"e(B:internal_encoding e$B$Ge(B Ruby
e$B$,JQ49$r9T$&$H!"LdBj$rGDe(B
e$B0.$9$k$N$Ke(B Windows e$B$NCN<1$He(B Ruby
e$B$NCN<1$NN>J}$,I,MW$K$J$j$^e(B
e$B$9!#e(B:internal_encoding e$B$,$J$1$l$P!"e(BWindows
e$B$NCN<1$@$1$G:Q$_e(B
e$B$^$9!#e(B

Windows e$B$N;qNA$O@$$NCf$K$"$k$G$7$g$&$7!"CN$C$F$$$k?M$b$=$l$Je(B
e$B$j$K$$$k$G$7$g$&!#$7$+$7!“e(BRuby e$B$G$NJQ49$K4X$9$kCN<1$b!”$H$Je(B
e$B$k$H!“Fq0WEY$,$+$J$j$”$,$k$s$8$c$J$$$G$7$g$&$+!#e(B

e$BF($l$i$l$J$$$+$i$H$$$C$F!":$Fq$K$7$F$$$$$H$O;W$$$^$;$s!#e(B

:internal_encoding e$B$NM-MQ@-$,Dc$$$H$9$l$P!"$=$&$$$&5!G=$GLde(B
e$BBj$r:$Fq$K$9$k$N$O4V0c$C$F$$$k$H;W$$$^$9!#e(B

e$B$3$NJU$Oe(B transcode e$B$N<:GT;~$N%*%W%7%g%s3HD%$GB?>/$O!#e(B

e$B6qBNE*$K$O$I$&$9$k$s$G$7$g$&e(B?

e$B$?$H$($P!“e(B:internal_encoding => “ISO-8859-1” e$B$H;XDj$7$?>l9ge(B
e$B$G!”!V$“$$$&$($*!W$H$$$&%U%!%$%kL>$K=P2q$C$?;~!”$I$&$$$&CM$re(B
e$BJV$9$s$G$9$+e(B?

e$B$3$N%Q%C%A$@$H!"e(Breaddir e$B$,2?$rJV$9$+$K0MB8$7$^$9$,!"e(B
Windows e$B4D6-$K$*$$$Fe(B UTF-16LE e$B$+e(B locale e$B$+$I$A$i$+$7$+F@$i$l$^$;$s$h$M!#e(B

readdir e$B$,e(B UTF-16LE
e$B$G%U%!%$%kL>$rJV$9$N$OL5M}$8$c$J$$$G$9$+e(B?

Windows e$B$Ne(B Unicode e$B%U%!%$%kL>$O8=:_07$o$l$F$$$^$;$s$N$G!"e(B
locale e$B$N>l9g$7$+07$C$F$$$^$;$s!#e(BUnicode e$B%U%!%$%kL>$N<BAu$Oe(B
e$B8e$NOC$G$9!#e(B

e$B$^$H$a$k$H!“0J2<$NF0:n$,$G$-$kI,MW$,$”$k!<$G$9$+$M!#e(B

== e$B%G%U%)%k%He(B
Windows: UTF-16LE → locale e$B<+F0JQ49e(B
Unix: locale

== e$B@8e(B
Windows: UTF-8
Unix: locale

e$B$3$l$i$N$U$?$D$O!“e(B[ruby-dev:35617] e$B$G=R$Y$?!”%U%!%$%kL>$rJ8e(B
e$B;z$H$7$F@5$7$/07$($k$h$&$K$9$k@UG$$,e(B

  • e$B%W%m%0%i%`$G$J$/!“4D6-$K$”$ke(B
  • e$B%W%m%0%i%`<+?H$K$"$ke(B
    e$B$H$$$&$U$?$D$NN)>l$KBP1~$9$k$b$N$G!“I,MW$G$9$7!”=EMW$G$9!#e(B

== e$B6/@);XDje(B
Unix: e$BG$0U$Ne(B encoding e$B$Ke(B force_encoding

e$B$3$l$O$H$/$KI,MW@-$,9b$$$H$O;W$C$F$$$^$;$s!#e(B
Unix e$B$G$O!“$”$C$F$bLdBj$J$$$+$b$7$l$^$;$s$,!#e(B

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

sheepman wrote:

e$B$=$N%G%U%)%k%HCM$,e(B Encoding.default_external e$B$H$O$^$C$?$/4X78$J$$e(B
e$B$H$$$&$N$O:.Mp$N85$@$H;W$$$^$9!#e(B

:internal_encoding e$B$,>C$($?$N$b$"$C$FL>>N$NJQ99$O9M$($F$$$^$9!#e(B
e$B$9$C$-$j$^$H$^$l$Pe(B :encoding
e$B$G$b$$$$$+$J!<$H;W$C$F$$$k$N$G$9$,!#e(B

e$B$H$j$"$($:e(B 1.9.1 e$B$^$G$K$OJQ$($^$9!#e(B

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

e$B$=$m$=$me(Bfeature freezee$B$,6a$$$N$G3NG’%b!<%I$G$9!#e(B

In message “Re: [ruby-dev:35689] Re: non-locale filename encoding”
on Tue, 29 Jul 2008 23:01:03 +0900, “NARUSE, Yui”
[email protected] writes:

|> external_encoding e$B$H$$$&L>A0$r$d$a$F!“e(Bfs_encoding e$B$J$I$Ke(B
|> e$BJQ$($k$H$$$&$N$O$I$&$G$7$g$&$+!#e(Bexternal_encoding e$B$H$$$&L>A0$J$N$Ke(B
|> e$B$=$N%G%U%)%k%HCM$,e(B Encoding.default_external e$B$H$O$^$C$?$/4X78$J$$e(B
|> e$B$H$$$&$N$O:.Mp$N85$@$H;W$$$^$9!#e(B
|
|:internal_encoding e$B$,>C$($?$N$b$”$C$FL>>N$NJQ99$O9M$($F$$$^$9!#e(B
|e$B$9$C$-$j$^$H$^$l$Pe(B :encoding e$B$G$b$$$$$+$J!<$H;W$C$F$$$k$N$G$9$,!#e(B
|
|e$B$H$j$"$($:e(B 1.9.1 e$B$^$G$K$OJQ$($^$9!#e(B

e$B8=>u$Oe(Binternal_encodinge$B$,>C$($F!“e(Bexternal_encodinge$B$,;D$C$F$$e(B
e$B$k>uBV$G$9$,!”$3$l$O$3$l$G$+$^$$$^$;$s$+!)e(B localee$B$H0c$&%(%se(B
e$B%3!<%G%#%s%0$N$H$-$KFI$_9~$s$G$/$k%U%!%$%kL>$N%(%s%3!<%G%#%se(B
e$B%0$J$N$G!"e(Bencodinge$B$G==J,$G$O$J$$$+$H$O;W$$$^$9$,!#e(B

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

Yukihiro M. wrote:

|> e$B$H$$$&$N$O:.Mp$N85$@$H;W$$$^$9!#e(B
|
|:internal_encoding e$B$,>C$($?$N$b$"$C$FL>>N$NJQ99$O9M$($F$$$^$9!#e(B
|e$B$9$C$-$j$^$H$^$l$Pe(B :encoding e$B$G$b$$$$$+$J!<$H;W$C$F$$$k$N$G$9$,!#e(B
|
|e$B$H$j$"$($:e(B 1.9.1 e$B$^$G$K$OJQ$($^$9!#e(B

e$B8=>u$Oe(Binternal_encodinge$B$,>C$($F!“e(Bexternal_encodinge$B$,;D$C$F$$e(B
e$B$k>uBV$G$9$,!”$3$l$O$3$l$G$+$^$$$^$;$s$+!)e(B localee$B$H0c$&%(%se(B
e$B%3!<%G%#%s%0$N$H$-$KFI$_9~$s$G$/$k%U%!%$%kL>$N%(%s%3!<%G%#%se(B
e$B%0$J$N$G!"e(Bencodinge$B$G==J,$G$O$J$$$+$H$O;W$$$^$9$,!#e(B

e$B9M$($?8B$j$G$OLdBj$J$5$=$&$J$N$Ge(B r19246 e$B$Ge(B :encoding
e$B$KJQ$($^$7$?!#e(B

In article [email protected],
sheepman [email protected] writes:

external_encoding e$B$H$$$&L>A0$r$d$a$F!"e(Bfs_encoding e$B$J$I$Ke(B
e$BJQ$($k$H$$$&$N$O$I$&$G$7$g$&$+!#e(Bexternal_encoding e$B$H$$$&L>A0$J$N$Ke(B
e$B$=$N%G%U%)%k%HCM$,e(B Encoding.default_external e$B$H$O$^$C$?$/4X78$J$$e(B
e$B$H$$$&$N$O:.Mp$N85$@$H;W$$$^$9!#e(B

e$B$^$:e(B external_encoding e$B$,=<J,$KLr$KN)$D$N$+$I$&$+$r8!F$$9$ke(B
e$B$N$,$$$$$N$G$O$J$$$G$7$g$&$+!#e(B

e$BLr$KN)$?$J$$$N$G$"$l$PL>A0$K4X$7$F5DO@$9$k$^$G$b$J$/>C$;$P$$e(B
e$B$$$G$7$g$&!#e(B