Issue #11488 has been updated by Usaku NAKAMURA.

Backport changed from 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: UNKNOWN, 2.1: DONE, 2.2: REQUIRED

ruby_2_1 r51976 merged revision(s) 51685.

----------------------------------------
Bug #11488: String#index and #include? broken for wide encodings
https://bugs.ruby-lang.org/issues/11488#change-54306

* Author: Tom Stuart
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: DONE, 2.2: REQUIRED
----------------------------------------
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/