pub fn is_hidden(c: char) -> bool {
(c.is_control() && c != '\n' && c != '\t')
|| matches!(c, '\u{202A}'..='\u{202E}' | '\u{2066}'..='\u{2069}')
}
pub fn clean(text: &str) -> String {
text.chars().filter(|&c| !is_hidden(c)).collect()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn controls_and_bidi_overrides_are_dropped_but_line_breaks_and_tabs_stay() {
assert_eq!(clean("invoice\u{202E}fdp.exe"), "invoicefdp.exe");
assert_eq!(clean("a\u{1b}[2Jb\rc\u{7}d\u{9b}e"), "a[2Jbcde");
assert_eq!(clean("one\ntwo\tthree"), "one\ntwo\tthree");
assert_eq!(clean("עברית and العربية"), "עברית and العربية");
}
}