use std::borrow::Cow;
use icu_properties::CodePointMapDataBorrowed;
use icu_properties::props::GeneralCategory;
static GENERAL_CATEGORY: CodePointMapDataBorrowed<'static, GeneralCategory> =
CodePointMapDataBorrowed::new();
#[inline(always)]
fn is_nonspacing_mark(c: char) -> bool {
GENERAL_CATEGORY.get(c) == GeneralCategory::NonspacingMark
}
#[inline]
pub fn normalize(input: &str) -> Cow<'_, str> {
let Some((head, _)) = input.char_indices().find(|&(_, c)| is_nonspacing_mark(c)) else {
return Cow::Borrowed(input);
};
let mut out = String::with_capacity(input.len());
out.push_str(&input[..head]);
out.extend(input[head..].chars().filter(|&c| !is_nonspacing_mark(c)));
Cow::Owned(out)
}