On Fri, Jan 31, 2014 at 12:54 PM, Arup Rakshit <lists / ruby-forum.com> wrote:
> Hi,
>
> I found a code online when I was searching a solution to encoding
> related
>
> def replace_name(body, name)
>   body
>     .encode('UTF-8', 'binary', invalid: :replace, undef: :replace,
> replace: '')
>     .gsub(/joel/, name)
> end
>
> Except 'UTF-8', what are the other options are doing ?
>
> Could you tell me what is it doing and when I need to think of this in
> real time app?
>
> --
> Posted via http://www.ruby-forum.com/.

Here is where String#encode is documented:

2.1.x: http://www.ruby-doc.org/core-2.1.0/String.html#method-i-encode
2.0.x: http://www.ruby-doc.org/core-2.0.0/String.html#method-i-encode
1.9.3: http://www.ruby-doc.org/core-1.9.3/String.html#method-i-encode

all describe the options on the method.