Project

General

Profile

Actions

Bug #21176

open

Regression in case-insensitive matching for single-byte encodings

Added by ima1zumi (Mari Imaizumi) 3 days ago. Updated 1 day ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.5.0dev (2025-02-28T09:32:36Z master db4ea95219) +PRISM [arm64-darwin24]
[ruby-core:121271]

Description

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

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

Actions

Also available in: Atom PDF

Like0
Like0