You haven't really given enough info to solve this.

What encoding is your source file? How certain are you that it is UTF8 and
that it has always been UTF8? It could've been something else and then
someone carelessly converted it to something else.

Have you tried using the rails multibyte methods if available?
http://api.rubyonrails.org/classes/String.html#method-i-mb_chars

Have you tried using the iconv library to convert to true UTF8?

You can't test encoding issues on IRB. It's not the same as text coming
from an encoded file.

On Mon, Mar 30, 2015 at 12:14 PM, leam hall <leamhall / gmail.com> wrote:

> 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/>
>