Skip to content

Sometimes 'Σ' is not handled correctly in str.to_lowercase() #124714

Closed
@Marcondiro

Description

@Marcondiro

Hello,
Due to the optimization introduced with #97046, the to_lowercase conversion of some str containing the Σ char is incorrect.

Simple example:

fn main(){
    println!("{}", "aΣ".to_lowercase());
    println!("{}", "abcdefghijklmnopΣ".to_lowercase());
}

output:

aς
abcdefghijklmnopσ

The first conversion is correct while the second is not and should be abcdefghijklmnopς.

More generally, this happens when 'Σ' follows a 2 * USIZE_SIZE * K number of chars

use std::mem;

const USIZE_SIZE_BY_2: usize = 2 * mem::size_of::<usize>();
const K: usize = 1;

fn main() {
    let bug_string = "a".repeat(USIZE_SIZE_BY_2 * K) + "Σ";

    println!("{}", bug_string.to_lowercase());
}

Metadata

Metadata

Assignees

Labels

A-UnicodeArea: UnicodeC-bugCategory: This is a bug.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions