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.

···

--
Posted via http://www.ruby-forum.com/.

Ruby 1.9.2

···

--
Posted via http://www.ruby-forum.com/.

Oleg Igor 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

···

--
Posted via http://www.ruby-forum.com/\.

my choice:
main_page.force_encoding "UTF-8"
:slight_smile:

···

--
Posted via http://www.ruby-forum.com/.