Feature #3328: Kernel#p outputs as default_internal encoding, and so on
http://redmine.ruby-lang.org/issues/show/3328
e$B5/I<<Te(B: Masaya T.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$B%+%F%4%je(B: core, Target version: 1.9.x
e$BC.2H$G$9!#e(B
Feature #2102 [ruby-dev:39343]
e$B$Ge(BString#inspecte$B$K$D$$$F$O6/@)E*$Ke(Bencodinge$B$rB7$($k$h$&$K$J$j$^$7$?$,!"e(BSymbole$B$de(BRegexpe$B$K$D$$$F$O$=$&$J$C$F$*$i$:!"F1$8$h$&$J4JC1$K%(%i!<$K$J$k>uBV$K$J$C$F$$$^$9!#%f!<%6!<Dj5A$Ne(Binspecte$B$K$bF1MM$G$9!#$^$?$Ke(Binspecte$B$GJ8;z%3!<%I$N0c$$$,6hJL$G$-$^$;$s!#e(B
e$B$=$3$G!"e(BKernel#pe$B$GI=<($9$kA0$de(BArraye$B$de(BHashe$B$G3Fe(Binspecte$B7k2L$r%^!<%8$9$kA0$K!"e(BString#inspecte$B$HF1MM$J=hM}$r9T$&$N$O$I$&$G$7$g$&$+!)6qBNE*$K$Oe(Binspecte$B$GA[Dj$9$ke(BEncodinge$B$H0[$J$k>l9g$K!“Hse(BASCIIe$BJ8;z$r%(%9%1!<%WI=<($K$9$ke(BString#inspect_encodee$B$rDI2C$7!”$=$l$re(Brb_inspecte$B$+$i8F$V;v$rDs0F$7$?$$$H;W$$$^$9!#e(BASCIIe$BJ8;z$K$D$$$F$O<j$r2C$($J$$$?$a!"IT2D5U$G$9$,e$OLdBj$J$$$H;W$$$^$9!#e(B
e$B$48!F$$r$*4j$$$7$^$9!#e(B
e$B0J2<$K8=>u$HDs0F8e$N7k2L!"e(BKernel#pe$B$NDj5A$NJQ99$r<($7$^$9!#e(B
e$B$^$?$3$NJQ99$r9T$&e(Bpatche$B$rE:IU$7$^$9!#e(B
cat inspect.rb
-- encoding: utf-8 --
Encoding.default_external = “WINDOWS-31J”
STDOUT.set_encoding “WINDOWS-31J”
a = "e$B$“e(B”
su = a.intern
se = a.encode(“euc-jp”).intern
sw = a.encode(“windows-31j”).intern
ru= /#{a}/
re= /#{a.encode(“euc-jp”)}/
rw= /#{a.encode(“windows-31j”)}/
hash = { su => se }
p su,se,sw,ru,re,rw
p hash rescue p $!
p [ru,re,rw,su,se,sw] rescue p $!
ruby_org inspect.rb
:e$B$"e(B
:e$B$"e(B
:e$B$"e(B
/e$B$"e(B/
/e$B$"e(B/
/e$B$"e(B/
#<Encoding::CompatibilityError: incompatible character encodings: UTF-8
and EUC-JP>
#<Encoding::CompatibilityError: incompatible character encodings: UTF-8
and EUC-JP>
ruby_new inspect.rb
:\u3042
:\x{A4A2}
:e$B$"e(B
/\u3042/
/\x{A4A2}/
/e$B$"e(B/
{:\u3042=>:\x{A4A2}}
[/\u3042/, /\x{A4A2}/, /e$B$"e(B/, :\u3042, :\x{A4A2}, :e$B$"e(B]
e$B$^$?!"e(B
Encoding.default_external = “WINDOWS-31J”
STDOUT.set_encoding “WINDOWS-31J”
class A ;def inspect ; "e$B$“e(B”.encode(“euc-jp”) end ; end
p A.new
puts A.new.inspect
puts A.new.inspect.inspect_encode
e$B$N7k2L$,e(B
\x{A4A2}
e$B$"e(B
\x{A4A2}
e$B$H$J$j!"e(Bpe$B$NDj5A$,>/$7JQ$o$j$^$9!#e(B