Skip to content

Commit

Permalink
Merge pull request gfx-rs#67 from hecrj/fix/private-use-characters
Browse files Browse the repository at this point in the history
Stop emitting private use characters on macOS
  • Loading branch information
hecrj authored Nov 24, 2019
2 parents cfe9759 + bbeb035 commit 357f73c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion winit/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ pub trait Application: Sized {
));
}
},
WindowEvent::ReceivedCharacter(c) => {
WindowEvent::ReceivedCharacter(c)
if !is_private_use_character(c) =>
{
events.push(Event::Keyboard(
keyboard::Event::CharacterReceived(c),
));
Expand Down Expand Up @@ -379,3 +381,14 @@ fn spawn<Message: Send>(
thread_pool.spawn_ok(future);
}
}

// As defined in: http://www.unicode.org/faq/private_use.html
// TODO: Remove once https://github.com/rust-windowing/winit/pull/1254 lands
fn is_private_use_character(c: char) -> bool {
match c {
'\u{E000}'..='\u{F8FF}'
| '\u{F0000}'..='\u{FFFFD}'
| '\u{100000}'..='\u{10FFFD}' => true,
_ => false,
}
}

0 comments on commit 357f73c

Please sign in to comment.