aboutsummaryrefslogtreecommitdiff
path: root/src/utils/text.rs
blob: c07cceeb7ed14314f16c074805bfc7ce1f5a83f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
pub fn format_search(str: &String) -> String {
    unaccent(&str.to_lowercase())
}

pub fn unaccent(str: &String) -> String {
    str.chars().map(unaccent_char).collect()
}

pub fn unaccent_char(c: char) -> char {
    match c {
        'à' | 'â' => 'a',
        'ç' => 'c',
        'è' | 'é' | 'ê' | 'ë' => 'e',
        'î' | 'ï' => 'i',
        'ô' => 'o',
        'ù' | 'û' | 'ü' => 'u',
        _ => c,
    }
}