Encoding::CompatibilityError

Hello !

line:
res = main_page.scan(/#{pr}:(.*?)</table>/m).to_s

error:
in `scan’: incompatible encoding regexp match (UTF-8 regexp with
ASCII-8BIT string) (Encoding::CompatibilityError)

How to fix ?

Oleg.

Ruby 1.9.2

my choice:
main_page.force_encoding “UTF-8”
:slight_smile:

Oleg I. wrote:

in `scan’: incompatible encoding regexp match (UTF-8 regexp with
ASCII-8BIT string) (Encoding::CompatibilityError)

How to fix ?

It depends on where main_page and pr came from.

If you want the full gorey details, you can read string19.rb at