DATAのencoding

[email protected]>;3OB9-$G$9!#e(B

magic commente$B$,$"$l$Pe(BDATAe$B$Ne(Bencodinge$B$K$bH?1G$5$l$?J}$,e(B
e$B$h$$$N$G$O$J$$$G$7$g$&$+e(B?

% cat a.rb

-- encoding: utf-8 --

p ENCODING
p DATA.internal_encoding
p DATA.external_encoding
p DATA.read.encoding
p "e$B$e(B.encoding
END
e$B$"e(B
% ruby-trunk -vd a.rb
ruby 1.9.0 (2008-02-10 revision 15426) [i686-linux]
#Encoding:UTF-8
nil
#Encoding:US-ASCII
#Encoding:US-ASCII
#Encoding:UTF-8
%

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

In message Re: [ruby-dev:33696] Re: DATAe$B$Ne(Bencoding
on Mon, 11 Feb 2008 06:00:23 +0900, NARUSE, Yui
[email protected] writes:

|> magic commente$B$,$"$l$Pe(BDATAe$B$Ne(Bencodinge$B$K$bH?1G$5$l$?J}$,e(B
|> e$B$h$$$N$G$O$J$$$G$7$g$&$+e(B?
|
|e$B$3$s$J46$8$G$7$g$&$+!#e(B

e$B%3%_%C%H$7$F$/[email protected]$5$$!#e(B

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

Kazuhiro NISHIYAMA wrote:

[email protected]>;3OB9-$G$9!#e(B

magic commente$B$,$"$l$Pe(BDATAe$B$Ne(Bencodinge$B$K$bH?1G$5$l$?J}$,e(B
e$B$h$$$N$G$O$J$$$G$7$g$&$+e(B?

e$B$3$s$J46$8$G$7$g$&$+!#e(B

Index: ruby.c

ruby.c (revision 15426)
+++ ruby.c (working copy)
@@ -1192,8 +1192,8 @@ load_file(VALUE parser, const char *fnam
else {
enc = rb_usascii_encoding();
}

  • rb_funcall(f, rb_intern(set_encoding), 1,
    rb_enc_from_encoding(enc));
    tree = (NODE *)rb_parser_compile_file(parser, fname, f,
    line_start);
  • rb_funcall(f, rb_intern(set_encoding), 1,
    rb_parser_encoding(parser));
    if (script && rb_parser_end_seen_p(parser)) {
    rb_define_global_const(DATA, f);
    }