From: tom@... Date: 2015-08-25T16:08:54+00:00 Subject: [ruby-core:70592] [Ruby trunk - Bug #11488] [Open] String#index and #include? broken for wide encodings Issue #11488 has been reported by Tom Stuart. ---------------------------------------- Bug #11488: String#index and #include? broken for wide encodings https://bugs.ruby-lang.org/issues/11488 * Author: Tom Stuart * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- In Ruby 2.2.2, `String#index` and `#include?` work as expected for all encodings: ~~~ >> Encoding.list.reject(&:dummy?). reject { |e| 'abcdef'.encode(e).include?('def'.encode(e)) }. map(&:name) => [] ~~~ But in Ruby 2.2.3 and trunk, they have become broken for wide encodings: ~~~ >> Encoding.list.reject(&:dummy?). reject { |e| 'abcdef'.encode(e).include?('def'.encode(e)) }. map(&:name) => ["UTF-16BE", "UTF-16LE", "UTF-32BE", "UTF-32LE"] ~~~ This broke as a result of revision 51470 (trunk) / 51590 (2.2.3). I attach a test. ---Files-------------------------------- string-index-include-wide-bug.patch (1.18 KB) -- https://bugs.ruby-lang.org/