Regexp#fixed_encoding?

e$B@55,I=8=$K$O!"G$0U$Ne(B (ASCII e$B8_49$Je(B)
e$B%(%s%3!<%G%#%s%0$NJ8;zNse(B
e$B$H%^%C%A$5$;$i$l$k$+!“FCDj$N%(%s%3!<%G%#%s%0$NJ8;zNs$K$7$+%^%Ce(B
e$B%A$5$;$i$l$J$$$+$H$$$&<oN`$,$”$j$^$9!#e(B

e$B$=$N<oN`$rH=JL$9$k$?$a$K!"e(BRegexp#fixed_encoding? e$B$r:n$k$N$Oe(B
e$B$I$&$G$7$g$&$+!#e(B

% ./ruby -e ‘p /a/.fixed_encoding?’
false
% ./ruby -e ‘p /a/e.fixed_encoding?’
true

1.8 e$B$G$O$3$l$K;w$?>pJs$re(B Regexp#kcode e$B$GF@$i$l$^$7$?$,!“e(B1.9
e$B$K$Oe(B kcode e$B$,$”$j$^$;$s!#e(B

% ruby-1.8 -e ‘p /a/.kcode’
nil
% ruby-1.8 -e ‘p /a/e.kcode’
“euc”

e$BFbItE*$K$O!“e(Brb_reg_prepare_re e$B$He(B rb_reg_s_union
e$B$G$3$N>pJs$,e(B
e$BI,MW$@$C$?$N$G3g$j=P$7$F$”$j!"$9$G$K4X?t$H$7$FB8:_$7$^$9!#e(B

Index: re.c

— re.c (revision 14018)
+++ re.c (working copy)
@@ -2198,6 +2198,7 @@ Init_Regexp(void)
rb_define_method(rb_cRegexp, “casefold?”, rb_reg_casefold_p, 0);
rb_define_method(rb_cRegexp, “options”, rb_reg_options_m, 0);
rb_define_method(rb_cRegexp, “encoding”, rb_obj_encoding, 0); /* in
encoding.c */

  • rb_define_method(rb_cRegexp, “fixed_encoding?”,
    rb_reg_fixed_encoding_p, 0);

    rb_define_const(rb_cRegexp, “IGNORECASE”,
    INT2FIX(ONIG_OPTION_IGNORECASE));
    rb_define_const(rb_cRegexp, “EXTENDED”,
    INT2FIX(ONIG_OPTION_EXTEND));

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

In message “Re: [ruby-dev:32361] Regexp#fixed_encoding?”
on Mon, 26 Nov 2007 11:39:31 +0900, Tanaka A. [email protected]
writes:
|
|e$B@55,I=8=$K$O!"G$0U$Ne(B (ASCII e$B8_49$Je(B) e$B%(%s%3!<%G%#%s%0$NJ8;zNse(B
|e$B$H%^%C%A$5$;$i$l$k$+!"FCDj$N%(%s%3!<%G%#%s%0$NJ8;zNs$K$7$+%^%Ce(B
|e$B%A$5$;$i$l$J$$$+$H$$$&<oN$,$"$j$^$9!#e(B | |e$B$=$N<oN$rH=JL$9$k$?$a$K!"e(BRegexp#fixed_encoding? e$B$r:n$k$N$Oe(B
|e$B$I$&$G$7$g$&$+!#e(B

e$B$G$O!"$=$l$rDI2C$H$$$&$3$H$G!#e(B