From: David Springer Date: 2010-02-25T08:22:38+09:00 Subject: Re: How do I set the encoding on a regexp ? --000e0cd70e242ccac7048060f01c Content-Type: text/plain; charset=ISO-8859-1 My bad. I was running 1.9.1, which had no FIXEDENCODING. Regexp.constants => [:IGNORECASE, :EXTENDED, :MULTILINE, :ONCE, :ENC_NONE, :ENC_EUC, :ENC _SJIS, :ENC_UTF8] So things have changed since 1.9.1 If you are running 1.9.2 then use FIXEDENCODING and you should be fine. I THINK that you are saying with FIXEDENCODING is NOT to revert back to something like ASCII. BTW in 1.9.1 >> Regexp::ENC_EUC => 16 >> Regexp::ENC_SJIS => 16 >> Regexp::ENC_UTF8 => 16 On Wed, Feb 24, 2010 at 4:55 PM, Brian Candler wrote: > Perry Smith wrote: > > But the "fixed encoding" is a key part of the puzzle I was missing. > > Also, David, I had not bumped into the ENC_UTF8 constant yet. There are > > quite a few constants (like the 16 pointed out by David also) is a flag > > to make the encoding "fixed". > > 16 is just Regexp::FIXEDENCODING > > irb(main):001:0> Regexp::FIXEDENCODING > => 16 > > In the 1.9.2 I have here (r24186, 2009-07-18) there is no > Regexp::ENC_UTF8, so it must be relatively new. > > irb(main):002:0> Regexp::ENC_UTF8 > NameError: uninitialized constant Regexp::ENC_UTF8 > from (irb):2 > from /usr/local/bin/irb192:12:in `
' > irb(main):003:0> Regexp.constants > => [:IGNORECASE, :EXTENDED, :MULTILINE, :FIXEDENCODING] > > As for the third arg to Regexp.new, I have no idea. Documentation is not > Ruby's strong point at the best of times, but it's nonexistent for the > encoding stuff. > -- > Posted via http://www.ruby-forum.com/. > > -- David N. Springer Eau Claire, WI --000e0cd70e242ccac7048060f01c--