Default script encoding and -K option

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

[ruby-dev:33140] e$B$G$J$+$`$i$5$s$,=q$+$l$F$$$^$9$,!"e(B

On Thu, 17 Jan 2008 09:42:43 +0900
“U.Nakamura” [email protected] wrote:

e$B$=$7$F!“e(B1.9e$B$Oe([email protected]$N$?$a$K%5%]!<%[email protected]$+$ie(B
1.8e$B$HF1$8$h$&$KF0$+$;$k$O$:!”$J$N$G$9$,e(B…

1.9 e$B$Ne(B -K e$B%%W%7%g%s$O%0%m!<%P%k$G$O$J$$$N$G!"e(B
require e$B$7$?%i%$%V%i%j$K$O1F6A$r$
$h$$;$^$;$s!#e(B
e$B0J2<$N$h$&$Je(B shebang e$B$r=q$$$F$$$J$$%i%$%V%i%j$G$Oe(B
1.8 e$B$H0c$&F0:n$r$7$^$9!#e(B

$ cat t.rb
require ‘lib’
f(“e$B$$$m$Oe(B”)

$ cat lib.rb
def f(s)
p $& if /./ =~ “e$B4A;ze(B”
p $& if /./ =~ s
end

$ ruby-1.8 -vKe t.rb
ruby 1.8.6 (2007-12-02 patchlevel 5000) [i686-linux]
“e$B4Ae(B”
“e$B$$e(B”

$ ruby-1.9 -vKe t.rb
ruby 1.9.0 (2008-01-16 revision 0) [i686-linux]
“\xB4”
“e$B$$e(B”

e$B%3%^%s%I%i%$%s$Ne(B -K e$B%*%W%7%g%s$Oe(B shebang e$B$be(B magic
comment e$B$be(B
e$B=q$$$F$$$J$$%i%$%V%i%j$N%9%/%j%W%H%(%s%3!<%G%#%s%0$K$b:nMQ$9$k$H$$$&e(B
e$B$N$O$I$&$G$7$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:33156] default script encoding and -K option”
on Jan.17,2008 22:47:14, [email protected] wrote:
| > e$B$=$7$F!“e(B1.9e$B$Oe(B-Ke$B$r0[email protected]$N$?$a$K%5%]!<%[email protected]$+$ie(B
| > 1.8e$B$HF1$8$h$&$KF0$+$;$k$O$:!”$J$N$G$9$,e(B…
|
| 1.9 e$B$Ne(B -K e$B%%W%7%g%s$O%0%m!<%P%k$G$O$J$$$N$G!"e(B
| require e$B$7$?%i%$%V%i%j$K$O1F6A$r$
$h$$;$^$;$s!#e(B

e$B$J!"[email protected]$C$F!<e(B(AAry

| e$B%3%^%s%I%i%$%s$Ne(B -K e$B%*%W%7%g%s$Oe(B shebang e$B$be(B magic comment e$B$be(B
| e$B=q$$$F$$$J$$%i%$%V%i%j$N%9%/%j%W%H%(%s%3!<%G%#%s%0$K$b:nMQ$9$k$H$$$&e(B
| e$B$N$O$I$&$G$7$g$&$+!#e(B

e$B%i%$%V%i%j$Ke(Bshebange$B$,=q$$$F$"$k>l9g$O=>Mh$I$*$jL5;k$G$$$$$H;We(B
e$B$$$^$9$,!"e(Bmagic
commente$B$,$J$$%i%$%V%i%j$K4X$7$F$O%3%^%s%I%i%$e(B
e$B%s$^$?$O%a%$%s%9%/%j%W%H$Ne(Bshebange$B$Ne(B-Ke$B$,:[email protected]$H;W$$$^$9!#e(B

e$B$H$$$&$+!"%i%$%V%i%j$O$*$m$+!"%a%$%s%9%/%j%W%H$K$9$ie(B-Ke$B$,8z$+e(B
e$B$J$/$J$C$F$$$k$N$G$9$,!"$3$l$O$o$6$H$G$9$+e(B?
(r15099e$B$N$^$D$b$H$5$s$Ne(Bcommit)

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

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

In message “Re: [ruby-dev:33167] Re: default script encoding and -K
option”
on Fri, 18 Jan 2008 14:25:48 +0900, “U.Nakamura”
[email protected] writes:

|e$B%i%$%V%i%j$Ke(Bshebange$B$,=q$$$F$"$k>l9g$O=>Mh$I$*$jL5;k$G$$$$$H;We(B
|e$B$$$^$9$,!"e(Bmagic commente$B$,$J$$%i%$%V%i%j$K4X$7$F$O%3%^%s%I%i%$e(B
|e$B%s$^$?$O%a%$%s%9%/%j%W%H$Ne(Bshebange$B$Ne(B-Ke$B$,:[email protected]$H;W$$$^$9!#e(B

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

|e$B$H$$$&$+!"%i%$%V%i%j$O$*$m$+!"%a%$%s%9%/%j%W%H$K$9$ie(B-Ke$B$,8z$+e(B
|e$B$J$/$J$C$F$$$k$N$G$9$,!"$3$l$O$o$6$H$G$9$+e(B?
|(r15099e$B$N$^$D$b$H$5$s$Ne(Bcommit)

e$B$o$6$H$8$c$J$$$G$9!#$I$&$d$C$FD>$9$+$O$H$b$+$/!#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:33168] Re: default script encoding and -K option”
on Jan.18,2008 14:34:23, [email protected] wrote:
| |e$B$H$$$&$+!"%i%$%V%i%j$O$*$m$+!"%a%$%s%9%/%j%W%H$K$9$ie(B-Ke$B$,8z$+e(B
| |e$B$J$/$J$C$F$$$k$N$G$9$,!"$3$l$O$o$6$H$G$9$+e(B?
| |(r15099e$B$N$^$D$b$H$5$s$Ne(Bcommit)
|
| e$B$o$6$H$8$c$J$$$G$9!#$I$&$d$C$FD>$9$+$O$H$b$+$/!#e(B

e$BN;2r$G$9!#e(B

e$B$D$$$G$J$N$GJ9$-$^$9$,!“e(B–encodinge$B$Oe([email protected]$1:ne(B
e$BMQ$7$F%9%/%j%W%H$N%(%s%3!<%G%#%s%0$K$O:nMQ$7$J$$J}$,$$$$$N$Ge(B
e$B$O$J$$$+$H$$$&9M$($r;d$O;}$C$F$$$k$N$G$9$,!”$I$&$G$7$g$&$+e(B?
([email protected]$N$?$a$KN>J}$K:nMQ$9$k$^$^$Ge(BOK)
e$B$=$&$7$J$$$H!"e(BASCIIe$BHs8_49$N%(%s%3!<%G%#%s%0$re(B–encodinge$B$K;XDje(B
e$B$7$?>l9g$K!"e(Bmagic
commente$B$N$J$$%9%/%j%W%H$OA4$FF0:n$7$J$/$J$Ce(B
e$B$F$7$^$$$^$9!#e(B

[email protected]!"[email protected][email protected]$Ke(Bmagic
commente$B$r=q$3$&$M!W$H$$$&[email protected]$7$$e(B
e$B5$$,$9$k$N$G!"K\Ev$O$I$A$i$,$$$$$N$+$OH=CG$,$D$$$F$$$^$;$s!#e(B

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

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

In message “Re: [ruby-dev:33169] Re: default script encoding and -K
option”
on Fri, 18 Jan 2008 16:12:42 +0900, “U.Nakamura”
[email protected] writes:

|e$B$D$$$G$J$N$GJ9$-$^$9$,!“e(B–encodinge$B$Oe([email protected]$1:ne(B
|e$BMQ$7$F%9%/%j%W%H$N%(%s%3!<%G%#%s%0$K$O:nMQ$7$J$$J}$,$$$$$N$Ge(B
|e$B$O$J$$$+$H$$$&9M$($r;d$O;}$C$F$$$k$N$G$9$,!”$I$&$G$7$g$&$+e(B?
|([email protected]$N$?$a$KN>J}$K:nMQ$9$k$^$^$Ge(BOK)

e$BF10U$7$^$9!#e(B

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

At Fri, 18 Jan 2008 14:34:23 +0900,
Yukihiro M. wrote in [ruby-dev:33168]:

|e$B$H$$$&$+!"%i%$%V%i%j$O$*$m$+!"%a%$%s%9%/%j%W%H$K$9$ie(B-Ke$B$,8z$+e(B
|e$B$J$/$J$C$F$$$k$N$G$9$,!"$3$l$O$o$6$H$G$9$+e(B?
|(r15099e$B$N$^$D$b$H$5$s$Ne(Bcommit)

e$B$o$6$H$8$c$J$$$G$9!#$I$&$d$C$FD>$9$+$O$H$b$+$/!#e(B

e$B$3$s$J46$8$G$9$+!#e(B

Index: parse.y

— parse.y (revision 15114)
+++ parse.y (working copy)
@@ -4765,5 +4765,4 @@ rb_parser_compile_string(volatile VALUE
lex_gets_ptr = 0;
lex_input = s;

  • parser->enc = rb_enc_get(s);
    lex_pbeg = lex_p = lex_pend = 0;
    compile_for_eval = rb_parse_in_eval();
    @@ -5958,4 +5957,5 @@ parser_prepare(struct parser_params *par
    }
    pushback©;
  • parser->enc = rb_enc_get(lex_lastline);
    }

@@ -9690,7 +9690,4 @@ ripper_initialize(int argc, VALUE *argv,
}
parser_initialize(parser);

  • if (parser->parser_lex_gets == lex_get_str) {

  • parser->enc = rb_enc_get(src);

  • }

    parser->parser_ruby_sourcefile_string = fname2;
    Index: ruby.c
    ===================================================================
    — ruby.c (revision 15114)
    +++ ruby.c (working copy)
    @@ -1039,4 +1039,5 @@ load_file(VALUE parser, const char *fnam
    int line_start = 1;
    NODE *tree = 0;

  • rb_encoding *enc;

    if (!fname)
    @@ -1152,8 +1153,14 @@ load_file(VALUE parser, const char *fnam
    }
    if (opt->enc_index >= 0) {

  • rb_enc_associate_index(f, opt->enc_index);
  • enc = rb_enc_from_index(opt->enc_index);
    }
    else if (f == rb_stdin) {
  • rb_enc_associate(f, rb_locale_encoding());
  • enc = rb_locale_encoding();
  • }
  • else {
  • enc = 0;
  • }
  • if (enc) {
  • rb_funcall(f, rb_intern(“set_encoding”), 1,
    rb_enc_from_encoding(enc));
    }
    tree = (NODE *)rb_parser_compile_file(parser, fname, f,
    line_start);

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

In message “Re: [ruby-dev:33172] Re: default script encoding and -K
option”
on Fri, 18 Jan 2008 23:01:05 +0900, Nobuyoshi N.
[email protected] writes:

|Yukihiro M. wrote in [ruby-dev:33168]:
|> |e$B$H$$$&$+!"%i%$%V%i%j$O$*$m$+!"%a%$%s%9%/%j%W%H$K$9$ie(B-Ke$B$,8z$+e(B
|> |e$B$J$/$J$C$F$$$k$N$G$9$,!"$3$l$O$o$6$H$G$9$+e(B?
|> |(r15099e$B$N$^$D$b$H$5$s$Ne(Bcommit)
|>
|> e$B$o$6$H$8$c$J$$$G$9!#$I$&$d$C$FD>$9$+$O$H$b$+$/!#e(B
|
|e$B$3$s$J46$8$G$9$+!#e(B

e$B$(!<$H!“MW$9$k$KIaCJe(Brb_enc_associate()e$B$NBP>]$K$J$i$J$$e(BIOe$B$K$`e(B
e$B$j$d$je(B(e$B$7$+$bGK2uE*$Ke(B)[email protected]_Dj$9$k$N$,[email protected]$C$?$H$$$&$Ne(B
e$B$,JQ99$N<g$JM}M3$G$9!#$G!”$3$N%Q%C%A$Oe(Bset_encodinge$B$r8F$s$G$$e(B
e$B$k$N$G!"GK2uE*$O$H$b$+$/$A$g$C$H$h$/$J$C$F$^$9!#$G$b!"e(B
IO#[email protected]_Dj$7$?$N$C$Fe(Brb_enc_get()e$B$G<h$j=P$;$J$$$he(B
e$B$&$J5$$,$9$k$s$G$9$,!#5$$N$;$$!)e(B

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

At Fri, 18 Jan 2008 23:59:03 +0900,
Yukihiro M. wrote in [ruby-dev:33174]:

e$B$(!<$H!“MW$9$k$KIaCJe(Brb_enc_associate()e$B$NBP>]$K$J$i$J$$e(BIOe$B$K$`e(B
e$B$j$d$je(B(e$B$7$+$bGK2uE*$Ke(B)[email protected]_Dj$9$k$N$,[email protected]$C$?$H$$$&$Ne(B
e$B$,JQ99$N<g$JM}M3$G$9!#$G!”$3$N%Q%C%A$Oe(Bset_encodinge$B$r8F$s$G$$e(B
e$B$k$N$G!"GK2uE*$O$H$b$+$/$A$g$C$H$h$/$J$C$F$^$9!#$G$b!"e(B
IO#[email protected]_Dj$7$?$N$C$Fe(Brb_enc_get()e$B$G<h$j=P$;$J$$$he(B
e$B$&$J5$$,$9$k$s$G$9$,!#5$$N$;$$!)e(B

e$B:#EY$Oe(Blex_inpute$B$8$c$J$/$Fe(Blex_lastlinee$B$+$i<h$C$F$^$9!#e(B

DATAe$B$N$3$H$r9M$($k$HGK2uE*$G$J$$$H$$$1$J$$$s$8$c$J$$$+$H;W$$$^$9e(B
e$B$,!"e(BDATAe$B$N%(%s%3!<%G%#%s%0$O%9%/%j%W%H%(%s%3!<%G%#%s%0$H$OJLJ*$Ge(B
e$B$9$+e(B?

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

In message “Re: [ruby-dev:33175] Re: default script encoding and -K
option”
on Sat, 19 Jan 2008 00:44:00 +0900, Nobuyoshi N.
[email protected] writes:

|At Fri, 18 Jan 2008 23:59:03 +0900,
|Yukihiro M. wrote in [ruby-dev:33174]:
|> e$B$(!<$H!“MW$9$k$KIaCJe(Brb_enc_associate()e$B$NBP>]$K$J$i$J$$e(BIOe$B$K$`e(B
|> e$B$j$d$je(B(e$B$7$+$bGK2uE*$Ke(B)[email protected]_Dj$9$k$N$,[email protected]$C$?$H$$$&$Ne(B
|> e$B$,JQ99$N<g$JM}M3$G$9!#$G!”$3$N%Q%C%A$Oe(Bset_encodinge$B$r8F$s$G$$e(B
|> e$B$k$N$G!"GK2uE*$O$H$b$+$/$A$g$C$H$h$/$J$C$F$^$9!#$G$b!"e(B
|> IO#[email protected]_Dj$7$?$N$C$Fe(Brb_enc_get()e$B$G<h$j=P$;$J$$$he(B
|> e$B$&$J5$$,$9$k$s$G$9$,!#5$$N$;$$!)e(B
|
|e$B:#EY$Oe(Blex_inpute$B$8$c$J$/$Fe(Blex_lastlinee$B$+$i<h$C$F$^$9!#e(B

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

|DATAe$B$N$3$H$r9M$($k$HGK2uE*$G$J$$$H$$$1$J$$$s$8$c$J$$$+$H;W$$$^$9e(B
|e$B$,!"e(BDATAe$B$N%(%s%3!<%G%#%s%0$O%9%/%j%W%H%(%s%3!<%G%#%s%0$H$OJLJ*$Ge(B
|e$B$9$+e(B?

e$B$$$(!“F1$8$G$”$k$Y$-$G$7$g$&!#%3%_%C%H$7$F$/[email protected]$5$$!#e(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