you could Use

"mystr.scrub"

And write the sheebang in this way

#!/usr/bin/env ruby
#encoding: utf-8


That "encoding: utf-8" tells to Ruby wich encode shall use


Thread name: "Trying to deal with an "invalid multibyte char (UTF-8)" issue" 
Mail number: 1 
Date: Mon, Mar 30, 2015 
In reply to: leam hall 
>
> I'm trying to slurp through a file with Ruby 1.9.x and there are some
> characters in it that choke my script. The character sequence I've found so
> far is "+" and all the things I try to do with it gives something like:
> 
>    irb(main):007:0> mystr = ['+']
>    SyntaxError: (irb):7: invalid multibyte char (UTF-8)
>    (irb):7: invalid multibyte char (UTF-8)
>    (irb):7: syntax error, unexpected $end
> 
> The end goal is to wind up with these things being changed to either ASCII
> or UTF-8. Either one should be useable.
> 
> Thoughts?
> 
> Leam
> 
> -- 
> Mind on a Mission <http://leamhall.blogspot.com/>