Project

General

Profile

Bug #21176

Updated by ima1zumi (Mari Imaizumi) 1 day ago

In Ruby 3.4.2, case-insensitive regex matching (`/i`) worked as expected for single-byte encodings like ISO-8859-x. 
 However, in Ruby 3.5.0dev, characters such as `\u00F3 (ó)` and `\u00D3 (Ó)` are no longer considered equivalent under case-insensitive matching, causing the match to fail. 

 The likely cause is #16145 , which appears to have broken handling of `0x80–0xFF` in single-byte encodings. 

 ## Reproduction 

 ```ruby 
 enc = Encoding::ISO_8859_1 
 o_acute_lower = "\u00F3".encode(enc)    # ó 
 o_acute_upper = "\u00D3".encode(enc)    # Ó 

 puts /[x#{o_acute_lower}]/i =~ "abc#{o_acute_upper}" 
 ``` 

 - Ruby 3.4.2: outputs 3 (match successful) 
 - Ruby 3.5.0dev: outputs nil (match fails) 
     - ruby 3.5.0dev (2025-02-28T09:32:36Z master db4ea95219) +PRISM [arm64-darwin24] 

 I will submit PR to fix this. 

 https://github.com/ruby/ruby/pull/12889 

Back