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
http://github.com/candlerb/string19

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs