# \[Feature #3036\] String#encode(to, from, opt) $B$N(B opt\[:replace\] $B$K(B Hash

**URL:** <https://www.ruby-forum.com/t/feature-3036-string-encode-to-from-opt-b-n-b-opt-replace-b-k-b-hash/185915>\
**Category:** Development\
**Created:** [March 29, 2010, 9:11am UTC](https://www.ruby-forum.com/t/feature-3036-string-encode-to-from-opt-b-n-b-opt-replace-b-k-b-hash/185915 "2010-03-29T09:11:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yui\_NARUSE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8edcca/32.png) [@Yui\_NARUSE](https://www.ruby-forum.com/u/Yui_NARUSE)\
**Post date:** [March 29, 2010, 9:11am UTC](https://www.ruby-forum.com/t/feature-3036-string-encode-to-from-opt-b-n-b-opt-replace-b-k-b-hash/185915/1 "2010-03-29T09:11:56Z")

</div>

Feature #3036: String#encode(to, from, opt) e$B$Ne(B opt[:replace]  
e$B$Ke(B Hash  
[http://redmine.ruby-lang.org/issues/show/3036](http://redmine.ruby-lang.org/issues/show/3036)

e$B5/I\<\<Te(B: Yui NARUSE  
e$B%9%F!\<%?%9e(B: Assigned, e$BM%@hEYe(B: Normal  
e$BC4Ev\<Te(B: Yui NARUSE

[ruby-dev:40540] e$B$Ne(B String#encode(to, from, opt) e$B$Ne(B  
opt[:replace] e$B$Ke(B Hash e$B$NOC$r!"e(B  
e$BJL$K%A%1%C%H$H$7$F5/$3$7$F$\*$-$^$9e(B

String#encode(to, from, opt) e$B$Ne(B opt[:replace] e$B$Ke(B Hash  
e$B$rM?$($i$l$k$h$&$K$7$F!"e(B  
e$B$=$3$K!“JQ4985e(B encoding e$B$NJ8;ze(B =\>  
e$BJQ49@h$NJ8;z!”$H$$$&L$Dj5AJ8;z$Ne(B fallback  
e$BJQ49I=$rM?$($i$l$k$h$&$K$9$k!"e(B  
e$B$H$$$&$b$N$r:#9M$($F$$$^$9!#e(B  
e$B$3$l$@$HNc$($P!"e(B  
fallbacks = {  
?e$B!oe(BuE6AD =\> “[e$B$U$/$me(B]”,  
?e$B!oe(Bu{1F4BA} =\> “[e$B$$$9e(B]”  
}  
“e$B!oe(Bu{3042 E6AD 1F4BA}”.encode(“UTF8-KDDI”, replace: fallbacks) #=\>  
"e$B$“e(B[e$B$U$/$me(B][e$B$$$9e(B]”
