From: James Gray Date: 2008-09-15T22:50:25+09:00 Subject: [ruby-core:18605] Re: [Bug #564] Regexp fails on UTF-16 & UTF-32 character encodings On Sep 15, 2008, at 3:49 AM, Michael Selig wrote: > On Mon, 15 Sep 2008 18:08:14 +1000, Tanaka Akira wrote: > >> In article <48cddb5533ad_8725cd9524342@redmine.ruby-lang.org>, >> Michael Selig writes: >> >>> UTF-16 & UTF-32 (and maybe other non-ascii compatible encodings) >>> don't seem to be work as Regexp patterns. >>> >>> Regexp.new("abc".encode("UTF-16BE")) >>> ==> EncodingCompatibilityError: incompatible character encodings: >>> US-ASCII and UTF-16BE >> >> % ruby -ve 'p Regexp.new("abc".encode("UTF-16BE")) =~ >> "abc".encode("UTF-16BE")' >> ruby 1.9.0 (2008-09-15 revision 19356) [i686-linux] >> 0 > > I see, I have diagnosed the problem wrongly. I was using irb. > > ruby -ve 'p Regexp.new("abc".encode("UTF-16BE"))' > ruby 1.9.0 (2008-09-03 revision 19073) [i686-linux] > -e:1:in `p': incompatible character encodings: UTF-16BE and > ASCII-8BIT (EncodingCompatibilityError) > from -e:1:in `
' > > This is the error I was getting in irb, and I mistakenly assumed it > was from the Regexp::new. > It is a different problem - not as bad as I thought! So it's inspect() that has the issues, right? James Edward Gray II