Match against Regexp with the same encoding as str. Forces str to utf-8 in the case of dummy encodings.