Skip to content

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

Description

@smichaku

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().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions