$B!!$5$5$@$G$9!%(B
$B!!:G6a!$(BString#encode $B$O(B :fallback
$B%*%W%7%g%s$K$h$C$F!$CV49$G$-$J$$J8;z(B
$B$rCV$-49$($k$?$a$NJ8;z!JNs!K$N%F!<%V%k$rEO$9$3$H$,$G$-$k!$$H$$$&$3$H$rCN(B
$B$j$^$7$?!%(B
p “\u00A9”.encode(‘sjis’, fallback: {"\u00a9" => ‘©’})
#=> ‘©’
$B!!$?$@!$(Bfallback $B%*%W%7%g%s$O(B Hash
$B$N%G%U%)%k%H%O%s%I%i$r8+$F$/$l$J$$$h(B
$B$&$G$9!%(B
h = Hash.new{’?’}
h["\u00a9"] = ‘©’
p “\u00A9\u00AA”.encode(‘sjis’, fallback: h)
t.rb:3:in encode': U+00AA from UTF-8 to Shift_JIS (Encoding::UndefinedConversionError) from t.rb:3:in
’
$B!!%^%C%W$rCN$C$F$$$k$b$N$OFCDj$NJ8;z!JNs!K$K!$CN$i$J$$$b$N$O%F%-%H!<$K(B
“?”
$B$H$+$K$7$?$$!$$H$$$&MQES$O$"$k$s$8$c$J$$$+$H;W$&$N$G!$BP1~$7$FLc$($k(B
$B$H$$$$$s$8$c$J$$$+$H;W$&$s$G$9$,!$$I$&$G$7$g$&$+!%(B
$B!!(BProc $B$H$+!$(B#[]
$B$r;}$C$F$$$k%*%V%8%’%/%H0lHL$K9-$2$F$b$$$$$+$b$7$l$^$;(B
$B$s$,!$$=$NJU$O$*G$$;$7$^$9!%(B
–
// SASADA Koichi at atdot dot net
$B$9$G$K%Q%A%b%s$,%Q%C%A$r;}$C$F$k$h$&$G$9$,(B…$B!%(B
$B$^$D$b$H(B $B$f$-$R$m$G$9(B
In message “Re: [ruby-dev:42692] [Feature: trunk]
String#encode(:fallback) should accept default handler”
on Mon, 6 Dec 2010 21:04:18 +0900, SASADA Koichi [email protected]
writes:
|$B!!$?$@!$(Bfallback $B%%W%7%g%s$O(B Hash
$B$N%G%U%)%k%H%O%s%I%i$r8+$F$/$l$J$$$h(B
|$B$&$G$9!%(B
|
|h = Hash.new{‘?’}
|h[“\u00a9”] = ‘(c)’
|p “\u00A9\u00AA”.encode(‘sjis’, fallback: h)
|t.rb:3:in encode': U+00AA from UTF-8 to Shift_JIS |(Encoding::UndefinedConversionError) | from t.rb:3:in
’
|
|
|$B!!%^%C%W$rCN$C$F$$$k$b$N$OFCDj$NJ8;z!JNs!K$K!$CN$i$J$$$b$N$O%F%-%H!<$K(B
|“?” $B$H$+$K$7$?$$!$$H$$$&MQES$O$"$k$s$8$c$J$$$+$H;W$&$N$G!$BP1~$7$FLc$($k(B
|$B$H$$$$$s$8$c$J$$$+$H;W$&$s$G$9$,!$$I$&$G$7$g$&$+!%(B
|
|
|$B!!(BProc $B$H$+!$(B#[]
$B$r;}$C$F$$$k%%V%8%'%/%H0lHL$K9-$2$F$b$$$$$+$b$7$l$^$;(B
|$B$s$,!$$=$NJU$O$*G$$;$7$^$9!%(B
|# $B$9$G$K%Q%A%b%s$,%Q%C%A$r;}$C$F$k$h$&$G$9$,(B…$B!%(B
$B$3$NJQ99$K;?@.$7$^$9!#(B
$B@.@%$G$9!#(B
2010$BG/(B12$B7n(B7$BF|(B12:21 Yukihiro M. [email protected]:
|p “\u00A9\u00AA”.encode(‘sjis’, fallback: h)
|$B!!(BProc $B$H$+!$(B#[]
$B$r;}$C$F$$$k%*%V%8%'%/%H0lHL$K9-$2$F$b$$$$$+$b$7$l$^$;(B
|$B$s$,!$$=$NJU$O$*G$$;$7$^$9!%(B
|# $B$9$G$K%Q%A%b%s$,%Q%C%A$r;}$C$F$k$h$&$G$9$,(B…$B!%(B
$B$3$NJQ99$K;?@.$7$^$9!#(B
ruby/ruby.h $B$KDI2C$7$F$$$k(B VALUE rb_obj_is_method(VALUE); $B$K(B
/intern/ $B$r$D$1!"(B
$B%F%9%H$rDI2C$7$?$iCfED$5$s$N;}$C$F$$$?%Q%C%A$G$$$$$s$8$c$J$$$+$H;W$$$^$9!#(B
$B$$$l$A$c$C$F$/$@$5$$$^$;(B
チケット #4125 が更新されました。 (by Nobuyoshi N.)
ステータス OpenからClosedに変更
進捗 % 0から100に変更
This issue was solved with changeset r30118.
Koichi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
(2010/12/07 16:43), NARUSE, Yui wrote:
ruby/ruby.h $B$KDI2C$7$F$$$k(B VALUE rb_obj_is_method(VALUE); $B$K(B /intern/
$B$r$D$1!"(B
$B!!$J$i!$JL$K(B ruby/ruby.h
$B$K:$;$kI,MW$O$J$$$s$8$c$J$$$G$7$g$&$+!%(B