From: James Gray Date: 2009-08-12T23:35:46+09:00 Subject: Re: 1.9 String and M17N documentation On Aug 12, 2009, at 5:13 AM, Brian Candler wrote: > James Gray wrote: >> * Just FYI, you ask the following about Regexp::FIXEDENCODING: >> >> # FIXME: What is the purpose of this flag? >> >> I do try to explain that under Regexp Encodings in this article, if >> you are interested: >> >> http://blog.grayproductions.net/articles/miscellaneous_m17n_details > > "A fixed_encoding?() Regexp is one that will raise an > Encoding::CompatibilityError if matched against any String that > contains > a different Encoding from the Regexp itself." > > I think that's not exactly correct: > > $ irb19 --simple-prompt >>> re = /gro/u > => /gro/ >>> re.encoding > => # >>> re.fixed_encoding? > => true >>> str = "gro".force_encoding("ISO-8859-1") > => "gro" >>> re =~ str > => 0 > > AFAICS, it will only raise an error if the matched string is of a > different encoding *and* is not ascii_only? > >>> str = "gro\xdf".force_encoding("ISO-8859-1") > => "gro�" >>> re =~ str > Encoding::CompatibilityError: incompatible encoding regexp match > (UTF-8 > regexp with ISO-8859-1 string) Thanks for the correction. I've updated the article you quoted with a correction. James Edward Gray II