Roger Pack wrote:
> 
>> I was expecting both to be set to UTF-8.  There is no force_encoding
>> method for RegExp.
>> 
>> If I later try to use it on strings of type UTF-8, it can throw an
>> exception.
> 
> Do you have an example of this?  It might be a bug.
> 
> I did notice that
> 
> Regexp.new("Café").encoding
> 
> keeps it in UTF-8
> 
> so maybe it's optimizing it and when it doesn't "have to be" UTF-8 it is 
> leaving it as ASCII?

I'm not clear what you mean by an example other than what I put in the 
original note.

I think I'm going to open a bug report -- it might not be a bug but I 
sure am confused.  The "Pick Axe" book describes a third argument but I 
can't get that to work either.  "ri" for Ruby 1.9.1 does not describe 
the third argument at all -- but it does seem to exist at least.

It appears as if, as you pointed out, if the input string happens to be 
ASCII, then the regexp encoding is ascii and there doesn't seem to be 
anything you can do about it.

I'm testing on 1.9.1 p243.

But, due to another discussion thread, I think I want to be in 8 bit 
binary anyway in my case.  I'm not 100% positive my input is UTF-8.  Its 
suppose to be but I can't really trust it.

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