Issue #6167 has been updated by John Firebaugh.


Other incorrect results:

>> "\u0100\u0101".count("a", "\u0100")
=> 1
>> "\u0100\u0101".count("\u0100", "a")
=> 1

Both should be 0.
----------------------------------------
Bug #6167: String#count: wrong result for multiple complements of multi-byte characters
https://bugs.ruby-lang.org/issues/6167#change-24676

Author: John Firebaugh
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]


>> "\u0100\u0101".count("^\u0100", "^\u0101")
=> 2

Since multiple arguments are intersected, the expected result is 0. Compare:

>> "\u0080\u0081".count("^\u0080", "^\u0081")
=> 0

This takes a different path through tr_setup_table and returns the correct result.

Analogous bugs exists in String#squeeze and String#delete, which also use tr_setup_table.


-- 
http://bugs.ruby-lang.org/