From 5b09ff1dd03b4c3ecbf5b4b824e74da8a783bd64 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 21 Mar 2022 20:37:26 -0700 Subject: [PATCH] fix incorrect csi-u encoding with non-ascii characters refs: https://github.com/wez/wezterm/issues/1746 --- docs/changelog.md | 1 + termwiz/src/input.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index de8217980..fef930d02 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -15,6 +15,7 @@ As features stabilize some brief notes about them will accumulate here. #### Changed #### Updated and Improved #### Fixed +* Incorrect csi-u encoding with non-ascii characters. [#1746](https://github.com/wez/wezterm/issues/1746) ### 20220319-142410-0fcdea07 diff --git a/termwiz/src/input.rs b/termwiz/src/input.rs index 2bb6a59e2..d58fec0fb 100644 --- a/termwiz/src/input.rs +++ b/termwiz/src/input.rs @@ -576,13 +576,17 @@ fn ctrl_mapping(c: char) -> Option { }) } +fn is_ascii(c: char) -> bool { + (c as u32) < 0x80 +} + fn csi_u_encode( buf: &mut String, c: char, mods: Modifiers, encoding: KeyboardEncoding, ) -> Result<()> { - if encoding == KeyboardEncoding::CsiU { + if encoding == KeyboardEncoding::CsiU && is_ascii(c) { write!(buf, "\x1b[{};{}u", c as u32, 1 + encode_modifiers(mods))?; } else { let c = if mods.contains(Modifiers::CTRL) && ctrl_mapping(c).is_some() {