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hDj$J$I$N<j4V$rLLE]$/$5$,$i$J$1$l$P!$e(B
encoding e$B$r;XDj$7$Fe(B open e$B$7$FFI$_9~$s$Ge(B eval e$B$G$be(B
e$B$^$!2DG=$H8@$($P2DG=$JOC$J$s$G$9$,!%!%!%e(B

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

In message Re: [ruby-dev:33646] require/load/autoload e$B$Ne(B
encoding e$B%*%W%7%g%se(B
on Fri, 8 Feb 2008 07:23:52 +0900, Hidetoshi NAGAI
[email protected] writes:

|e$B8+$D$1$k$3$H$,$G$-$J$+$C$?$N$G5-210c$$$+$b$7$l$J$$$N$G$9$,!$e(B
|require e$BEy$N:]$Ke(B encoding e$B$r;XDj$9$k%*%W%7%g%s$H$$$&OC$,e(B
|e$B$A$i$C$H=P$F$$$?$h$&$J5$$,$7$^$9!%e(B
|e$B$3$l$OF3F~$5$l$kM=Dj$O$J$$$N$G$7$g$&$+!%e(B

e$B$"$s$^$j$J$$$G$9!"FC$Ke(Brequire/autoloade$B$K4X$7$F$O!#e(B

|Ruby 1.8 e$B$N;~$N%9%?%$%k$G!$%a%$%s%9%/%j%W%H$K$OF|K\8l$r4^$a$:!$e(B
|e$B%a%$%s%9%/%j%W%H$NCf$Ge(B $KCODE e$B$r;XDj$7$F!$e(B
|e$B$=$l$+$iF|K\8l$r4^$`ItJ,$re(B require e$B$9$k$H$$$&$N$,$$j$^$7$?!%e(B
|-K e$B%%W%7%g%s$rK:$l$?$j!$e(Bshebang e$B$,;H$o$l$J$$$h$&$J8F$P$lJ}$re(B
|e$B$7$?>l9g$G$b@5$7$/F0$/$h$&$K$9$k$?$a$G$9!%e(B
|require e$BEy$Ke(B encoding e$B;XDj%
%W%7%g%s$,$$l$P!$$=$NBe$j$K$G$-$^$9!%e(B
|
|e$B$b$A$m$s!VFI$_9~$^$l$k%U%!%$%k$Ke(B magic comment e$B$r;XDj$7$m!W$H$$$&$N$,e(B
|e$B$b$C$H$b$J<gD%$G$"$k$3$H$O$o$+$j$^$9!%e(B

e$BM=Dj$,$J$$M}M3$O%i%$%V%i%j$K$D$$$F$O$3$A$i$r;H$&J}$,$I$&9M$(e(B
e$B$F$b@5Ev$@$+$i$G$9!#e(B

|e$B$G$9$,!$2?$i$+$N%%W%j%1!<%7%g%s$N@_Dj%U%!%$%k$N$h$&$Ke(B
|e$BI,$:$7$be(B Ruby e$B$K=,=O$7$F$$$J$$%f!<%6$,JT=8$r9T$&2DG=@-$,$$k:]$K$Oe(B
|e$B$*$^$8$J$$$N$h$&$Je(B magic comment e$B$O$J$/$F$b$9$^$;$i$l$kJ}$,e(B
|e$B8mJT=8$K$h$k%H%i%V%k$,>/$J$/$J$k$H;W$$$^$9!%e(B

e$B$4;XE&$N$h$&$K%i%$%V%i%j$G$J$/@_Dj%U%!%$%k$N$h$&$J>l9g$K$O!e(B
e$B$$k$$$O30$+$i%(%s%3!<%G%#%s%0$r;XDj$9$k$N$bNI$$$N$+$b$7$l$^e(B
e$B$;$s$,!"$=$N>l9g$K$Oe(B

|e$B%U%!%$%k%Q%9$N7hDj$J$I$N<j4V$rLLE]$/$5$,$i$J$1$l$P!$e(B
|encoding e$B$r;XDj$7$Fe(B open e$B$7$FFI$_9~$s$Ge(B eval e$B$G$be(B
|e$B$^$!2DG=$H8@$($P2DG=$JOC$J$s$G$9$,!%!%!%e(B

e$B$H$9$k$Y$-$@$H;W$$$^$9!#$=$N$h$&$J;H$$J}$,==J,$KB?$$$H$$$&OCe(B
e$B$G$$l$P!$$k$$$Oe(Bloade$B$K$=$N$h$&$J5!G=$rIU2C$9$kM>CO$O$$k$+e(B
e$B$b$7$l$^$;$s$,!"EvLL$OAH$9~$$H$9$k$h$j$O30It%i%$%V%i%j$K$9e(B
e$B$Y$-$G$O$J$$$+$H!#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:33647] Re: require/load/autoload e$B$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W%He(B (e$B%i%$%V%i%je(B) e$B>e$G@8@.$5$l$kJ8;zNs$N%G%U%)%k%H$Ne(B encoding e$B$re(B
e$B$=$l$rMxMQ$9$k%9%/%j%W%HB&$NET9g$K9g$o$;$Fe(B
e$B$&$^$/%3%s%H%m!<%k$G$-$?$j$9$k$N$+$b$H;W$C$?$b$N$Ge(B
e$B$*?R$M$7$^$7$?!%e(B

[ruby-dev:33488]
e$B$H$+$N1dD9$J$N$@$H;W$$$^$9$,!"8=;~E@$G$O%H%j%C%-!<$JJ}e(B
e$BK!$GMxMQ<T$NJX59$r?^$k$N$O$d$a$?J}$,$$$$$H;W$$$^$9!#AGD>$Ke(B
e$B!Ve(BTk.encoding_system
e$B$r@_Dj$7$^$7$g$&!W$H8@$C$F$*$$$?J}$,L5Fq$G$7$g$&!#e(B

e$B$3$N<j$NLdBj$Oe(B Win32OLE e$B$de(B [ruby-dev:33550] e$B$Ne(B
Object#inspecte$B!e(B[ruby-
dev:33303] e$B$Ne(B Time#strftime
e$BEyJ}!9$GH/8+$5$l$F$$$k$N$G!>-MhE*$KE}0lE*$Je(B
e$BJ}K!$,3NN)$5$l$?$i$=$l$K>h$k$N$,$h$$$+$H!#e(B

e$B0l$D$NJ}K!$H$7$F!8=:_$Ne(B Encoding.default_external
e$B0J30$K!$=$N%"%W%je(B
e$B%1!<%7%g%s$N<g$?$kFbIt%(%s%3!<%G%#%s%0$rL@<($9$kJ}K!$rMQ0U$9$k!=!=Nc$($Pe(B
Encoding.primary_encoding
e$B$r:n$l$P$$$$$+$J$!$H;W$C$F$$$k$N$G$9$,1F6AHO0Oe(B
e$B$r$^$@9M$($-$l$F$$$^$;$s!#e(B

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

From: NARUSE, Yui [email protected]
Subject: [ruby-dev:33649] Re: require/load/autoload e$B$Ne(B encoding
e$B%*%W%7%g%se(B
Date: Fri, 8 Feb 2008 11:22:13 +0900
Message-ID: [email protected]

[ruby-dev:33488] e$B$H$+$N1dD9$J$N$@$H;W$$$^$9$,!"8=;~E@$G$O%H%j%C%-!<$JJ}e(B
e$BK!$GMxMQ<T$NJX59$r?^$k$N$O$d$a$?J}$,$$$$$H;W$$$^$9!#AGD>$Ke(B
e$B!Ve(BTk.encoding_system e$B$r@_Dj$7$^$7$g$&!W$H8@$C$F$*$$$?J}$,L5Fq$G$7$g$&!#e(B

e$B%H%j%C%-!<$G$7$?$+$M!)e(B
e$BL@<(E*$J;XDj$J$N$G!$$=$3$^$G$O$J$$$H;W$C$?$N$G$9$,!%e(B(^_^;

e$B$A$J$_$Ke(B Tk e$B$G$Oe(B Tk.encoding_system e$B$He(B Tk
e$B$+$iJV$9J8;zNs$Ne(B
e$B%G%U%)%k%H$Ne(B encoding e$B$H$OJL!9$K;XDj$9$k$3$H$,$G$-$k$h$&$Ke(B
e$B$9$kM=Dj$G$9e(B (e$B>/$J$/$H$b8=;~E@$G$O$G$9$,e(B)e$B!%e(B

Tk.encoding_system e$B$Oe(B Tk e$B>e$Ne(B I/O e$B$G;H$o$l$k$N$Ge(B

Encoding.default_external e$B$KB7$($k$,!$e(B

e$B%9%/%j%W%H>e$G07$$$?$$J8;zNs$OI,$:$7$be(B default_external

e$B$H$Oe(B

e$B0lCW$7$J$$$H9M$($i$l$k$?$a!%e(B

e$B$3$N<j$NLdBj$Oe(B Win32OLE e$B$de(B [ruby-dev:33550] e$B$Ne(B Object#inspecte$B!e(B[ruby-
dev:33303] e$B$Ne(B Time#strftime e$BEyJ}!9$GH/8+$5$l$F$$$k$N$G!>-MhE*$KE}0lE*$Je(B
e$BJ}K!$,3NN)$5$l$?$i$=$l$K>h$k$N$,$h$$$+$H!#e(B

e$B$=$&$J$k$N$G$7$?$i!$B?J,!$$=$l$KAGD>$K>h$C$+$k$@$m$&$H;W$$$^$9!%e(B

e$B0lBN$I$l$,e(B 1.9

e$B$N3NDj;EMM$G!$$I$3$,;CDje(B/e$BJQ99$N2DG=@-$"$j$G!$e(B

e$B2?$,$I$&$$$&7A$G:#8e$N<BAuM=Dj$H$J$C$F$$$k$N$+$,e(B

e$B$o$+$C$F$J$/$F$9$_$^$;$s!%e(B

e$B0l$D$NJ}K!$H$7$F!8=:_$Ne(B Encoding.default_external e$B0J30$K!$=$N%"%W%je(B
e$B%1!<%7%g%s$N<g$?$kFbIt%(%s%3!<%G%#%s%0$rL@<($9$kJ}K!$rMQ0U$9$k!=!=Nc$($Pe(B
Encoding.primary_encoding e$B$r:n$l$P$$$$$+$J$!$H;W$C$F$$$k$N$G$9$,1F6AHO0Oe(B
e$B$r$^$@9M$($-$l$F$$$^$;$s!#e(B

e$B%0%m!<%P%k$J$b$N$O$^$D$b$H$5$s$K7y$,$i$l$F$^$9$+$i!$e(B
Thread e$B%m!<%+%k$^$?$Oe(B ThreadGroup e$B%m!<%+%k$/$i$$$Ge(B
e$B@_Dj$9$k$b$N$J$i$$$$$N$G$7$g$&$+!%!%!%e(B

ThreadGroup e$B%m!<%+%k$G$Oe(B Thread safe

e$B$G$O$J$$$+$i%@%a$+$J!)e(B

Thread e$B%m!<%+%k$N>l9g$K$O!$?7$7$$%9%l%C%I$Ne(B primary_encoding

e$B$Oe(B

e$B@[email protected](B Thread e$B$Ne(B primary_encoding

e$B$r0z$-7Q$0$H$$$&$3$H$G!%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:33651] Re: require/load/autoload e$B$Ne(B encoding
e$B%*%W%7%g%se(B
on Feb.08,2008 13:20:02, [email protected] wrote:
| > e$B0l$D$NJ}K!$H$7$F!8=:_$Ne(B Encoding.default_external e$B0J30$K!$=$N%"%W%je(B
| > e$B%1!<%7%g%s$N<g$?$kFbIt%(%s%3!<%G%#%s%0$rL@<($9$kJ}K!$rMQ0U$9$k!=!=Nc$($Pe(B
| > Encoding.primary_encoding e$B$r:n$l$P$$$$$+$J$!$H;W$C$F$$$k$N$G$9$,1F6AHO0Oe(B
| > e$B$r$^$@9M$($-$l$F$$$^$;$s!#e(B
|
| e$B%0%m!<%P%k$J$b$N$O$^$D$b$H$5$s$K7y$,$i$l$F$^$9$+$i!$e(B
| Thread e$B%m!<%+%k$^$?$Oe(B ThreadGroup e$B%m!<%+%k$/$i$$$Ge(B
| e$B@_Dj$9$k$b$N$J$i$$$$$N$G$7$g$&$+!%!%!%e(B

e$B$^$D$b$H$5$s$,7y$C$F$$$k$N$O%0%m!<%P%k$J>uBV$NF3F~$@$C$?$N$Ge(B
e$B$O$J$$$+$H;W$$$^$9!#e(B
e$B$G$9$+$i!JQ99$,IT2DG=$J%0%m!<%P%k$JJQ?t$J$i$$j$($k$N$G$O$Je(B
e$B$$$G$7$g$&$+!#e(B

e$BNc$($P!"e(BEncoding.primary_encodinge$B$NCM$H$7$F$O%a%$%s%9%/%j%W%He(B
e$B$Ne(Bscript encodinge$B$,@_Dj$5$l!"JQ99$OITG=!6/EY$Oe(Bmagic comment
e$B$h$j$b<e$$e(B e$B$H$$$&$N$O$$j$($k$N$G$O$J$$$+$H;W$$$^$9!#e(B

e$B$3$NDj5A$GMQ0U$5$l$?$b$N$,JXMx$+$I$&$+$O8!F$$7$F$^$;$s$,e(B

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

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

From: U.Nakamura [email protected]
Subject: [ruby-dev:33659] Re: require/load/autoload e$B$Ne(B encoding
e$B%*%W%7%g%se(B
Date: Fri, 8 Feb 2008 21:07:44 +0900
Message-ID: [email protected]

| e$B%0%m!<%P%k$J$b$N$O$^$D$b$H$5$s$K7y$,$i$l$F$^$9$+$i!$e(B
| Thread e$B%m!<%+%k$^$?$Oe(B ThreadGroup e$B%m!<%+%k$/$i$$$Ge(B
| e$B@_Dj$9$k$b$N$J$i$$$$$N$G$7$g$&$+!%!%!%e(B

e$B$^$D$b$H$5$s$,7y$C$F$$$k$N$O%0%m!<%P%k$J>uBV$NF3F~$@$C$?$N$Ge(B
e$B$O$J$$$+$H;W$$$^$9!#e(B
e$B$G$9$+$i!JQ99$,IT2DG=$J%0%m!<%P%k$JJQ?t$J$i$$j$($k$N$G$O$Je(B
e$B$$$G$7$g$&$+!#e(B

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

e$BNc$($P!"e(BEncoding.primary_encodinge$B$NCM$H$7$F$O%a%$%s%9%/%j%W%He(B
e$B$Ne(Bscript encodinge$B$,@_Dj$5$l!"JQ99$OITG=!6/EY$Oe(Bmagic comment
e$B$h$j$b<e$$e(B e$B$H$$$&$N$O$$j$($k$N$G$O$J$$$+$H;W$$$^$9!#e(B

e$B$3$NDj5A$GMQ0U$5$l$?$b$N$,JXMx$+$I$&$+$O8!F$$7$F$^$;$s$,e(B

e$BJQ99ITG=$@$H3hMQ2DG=$JHO0O$,69$a$i$l$F$7$^$$$=$&$G$9$,!$e(B
e$B%a%$%s%9%/%j%W%H$Ne(B encoding e$B$rCN$k$3$H$,$G$-$k$@$1$G$be(B
e$B3N$+$KLr$KN)$D$+$b$7$l$^$;$s$M!%e(B

e$BJQ992DG=$J>l9g$N3hMQJ}K!$O8!F$$7$F$$$^$;$s!%e(B(^_^;

e$B$G$b$=$&$$$&$b$N$G$"$k$J$i!$%a%=%C%I$K$9$k$h$j$be(B
ENCODING e$B$H$NBPHf$Ge(B PRIMARY_ENCODING e$B$H$$$&e(B
e$BJQ?t$K$9$kJ}$,2?$H$J$/NI$5$=$&$K46$8$^$9!%e(B

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

NARUSE, Yui wrote:

e$B0l$D$NJ}K!$H$7$F!8=:_$Ne(B Encoding.default_external e$B0J30$K!$=$N%"%W%je(B
e$B%1!<%7%g%s$N<g$?$kFbIt%(%s%3!<%G%#%s%0$rL@<($9$kJ}K!$rMQ0U$9$k!=!=Nc$($Pe(B
Encoding.primary_encoding e$B$r:n$l$P$$$$$+$J$!$H;W$C$F$$$k$N$G$9$,1F6AHO0Oe(B
e$B$r$^$@9M$($-$l$F$$$^$;$s!#e(B

e$B$H$j$"$($:e(B default_internal e$B$H$$$&$b$N$r:n$C$F$_$^$7$?!#e(B

e$BNc$($P!e(Binspect e$B$NNc$G$9$H!e(B
irb(main):006:0> [\x82\xa0.force_encoding(sjis),
irb(main):007:1* \xa4\xa2.force_encoding(euc-jp),
irb(main):008:1* \xe3\x81\x82.force_encoding(utf-8)]
=> ["\x82\xA0", \xA4\xA2, "e$B$e(B]
e$B$3$s$J46$8$K$J$j$^$9!#e(B

=== encoding.c

encoding.c (revision 15414)
+++ encoding.c (local)
@@ -1030,6 +1030,40 @@
return rb_enc_from_index(idx);
}

+static int default_internal_index;
+
+rb_default_internal_encoding(void)

  • return rb_enc_from_index(default_internal_index);

+VALUE
+rb_enc_default_internal(void)
+{

  • return rb_enc_from_encoding(rb_default_internal_encoding());
    +}

+/*

    • call-seq:
    • Encoding.default_internal => enc
    • Returns default internal encoding.
    • It is initialized by the encoding of main script.
  • */
    +static VALUE
    +get_default_internal(VALUE klass)
    +{
  • return rb_enc_default_internal();
    +}

+void
+rb_enc_set_default_internal(VALUE encoding)
+{

  • default_internal_index = rb_enc_to_index(rb_to_encoding(encoding));
    +}

static int default_external_index;

rb_encoding *
@@ -1246,6 +1280,7 @@
rb_define_method(rb_cEncoding, _dump, enc_dump, -1);
rb_define_singleton_method(rb_cEncoding, _load, enc_load, 1);

  • rb_define_singleton_method(rb_cEncoding, default_internal,
    get_default_in
    ternal, 0);
    rb_define_singleton_method(rb_cEncoding, default_external,
    get_default_ex
    ternal, 0);
    rb_define_singleton_method(rb_cEncoding, locale_charmap,
    rb_locale_charma
    p, 0);

=== string.c

string.c (revision 15414)
+++ string.c (local)
@@ -3314,7 +3314,7 @@
VALUE
rb_str_inspect(VALUE str)
{

  • rb_encoding *enc = STR_ENC_GET(str);
  • rb_encoding *enc = rb_default_internal_encoding();
    char *p, *pend;
    VALUE result = rb_str_buf_new2("");

=== ruby.c

ruby.c (revision 15414)
+++ ruby.c (local)
@@ -1021,6 +1021,7 @@
rb_enc_associate(opt->e_script, eenc);
require_libraries();
tree = rb_parser_compile_string(parser, opt->script,
opt->e_script, 1);

  •   rb_enc_set_default_internal(rb_parser_encoding(parser));
    
    }
    else {
    if (opt->script[0] == - && !opt->script[1]) {
    @@ -1200,6 +1201,9 @@
    else if (f != rb_stdin) {
    rb_io_close(f);
    }
  • rb_enc_set_default_internal(rb_parser_encoding(parser));
  • if (rb_default_internal_encoding() == rb_usascii_encoding())

rb_enc_set_default_internal(rb_enc_from_encoding(rb_locale_encoding()));
return tree;
}

=== include/ruby/encoding.h

include/ruby/encoding.h (revision 15414)
+++ include/ruby/encoding.h (local)
@@ -164,9 +164,12 @@
rb_encoding *rb_utf8_encoding(void);
rb_encoding *rb_usascii_encoding(void);
rb_encoding *rb_locale_encoding(void);
+rb_encoding *rb_default_internal_encoding(void);
rb_encoding *rb_default_external_encoding(void);
int rb_usascii_encindex(void);
+VALUE rb_enc_default_internal(void);
VALUE rb_enc_default_external(void);
+void rb_enc_set_default_internal(VALUE encoding);
void rb_enc_set_default_external(VALUE encoding);
VALUE rb_locale_charmap(VALUE klass);