Merge pull request #2295 from iced-rs/ignore-private-use-chars

Ignore `text` in `KeyPressed` with private use chars
This commit is contained in:
Héctor Ramón 2024-02-26 06:14:07 +01:00 committed by GitHub
commit 58a7007ac1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -224,7 +224,7 @@ pub fn window_event(
// TODO: Fix inconsistent API on Wasm
event.text
}
};
}.filter(|text| !text.as_str().chars().any(is_private_use));
let winit::event::KeyEvent {
state, location, ..
@ -839,3 +839,8 @@ pub fn icon(icon: window::Icon) -> Option<winit::window::Icon> {
winit::window::Icon::from_rgba(pixels, size.width, size.height).ok()
}
// See: https://en.wikipedia.org/wiki/Private_Use_Areas
fn is_private_use(c: char) -> bool {
('\u{E000}'..='\u{F8FF}').contains(&c)
}