wildmatch icon indicating copy to clipboard operation
wildmatch copied to clipboard

Case-insensitive UNICODE matching is not supported for non-ASCII characters

Open smichaku opened this issue 4 months ago • 1 comments

Describe the bug

Case insensitive matching is not supported for all languages (e.g. Russian).

To Reproduce

The following program demonstrates the issue:

fn test_english() {
    let base = "file";

    let expression = base;
    let name = base.to_uppercase();

    println!("Expression lowercase: {}", expression);
    println!("Expression uppercase: {}", expression.to_uppercase());

    println!("Name lowercase: {}", name.to_lowercase());
    println!("Name uppercase: {}", name);

    let matcher = wildmatch::WildMatch::new_case_insensitive(&expression);
    assert!(matcher.matches(&name));

    println!("English test passed.");
}

fn test_russian() {
    let base = "файл";

    let expression = base;
    let name = base.to_uppercase();

    println!("Expression lowercase: {}", expression);
    println!("Expression uppercase: {}", expression.to_uppercase());

    println!("Name lowercase: {}", name.to_lowercase());
    println!("Name uppercase: {}", name);

    let matcher = wildmatch::WildMatch::new_case_insensitive(&expression);
    assert!(matcher.matches(&name));

    println!("Russian test passed.");
}

fn main() {
    test_english();
    test_russian();
}

Expected behavior

Both tests should pass.

Additional context I think the problem might be the use of to_ascii_lowercase() in matches().

smichaku avatar Sep 02 '25 17:09 smichaku

Fix PR

smichaku avatar Sep 02 '25 17:09 smichaku