Invalid byte sequence in UTF-8 (ArgumentError)

I’m trying to run a Ruby script, and always getting an error on this


Where I’m trying to replace “dr” by “med”.

The error is:

program.rb:4:in `gsub’: invalid byte sequence in UTF-8 (ArgumentError)

Why is that, how can I fix this issue?

Provided that I’m working on a MAC OS X Yosemite machine, with ruby


Probably the problem is related to encodings. Check out the encoding of
file_content calling him #encoding(), it is diferent from utf-8? You
could go that way…