rutrum / convert-case

Converts to and from various cases.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

to_case() - Fail with words with accent mark

trapalleiro-git opened this issue · comments

to_case() fail with words With accent mark. Example: música moderna.

Thank you for bringing this up. I made the mistake of manually stepping through bytes of strings, when they may not necessarily be character boundaries for non-ascii characters. The algorithm I made breaks character boundaries in this case. The solution is to integrate the "unicode-segmentation" library to step through strings without failing. This is in development, and will update this issue when it is resolved. Thanks again for the issue.

I have added unicode-segmentation as a dependency, and added a test which specifically addresses the string you provided. The newest version, convert-case version 0.6.0 fixes this issue.

convert-case/src/lib.rs

Lines 650 to 653 in a8702a0

fn accent_mark() {
let s = "música moderna".to_string();
assert_eq!("MúsicaModerna", s.to_case(Case::Pascal));
}