mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Show un-decodable inputs as bytes instead of the internal encoding
When the input is invalid UTF8, we re-encode the raw bytes using the private use area. Let's make sure we convert back before printing.
This commit is contained in:
parent
182f8948b8
commit
53ea6db72d
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
common::{escape_string, EscapeFlags, EscapeStringStyle},
|
common::{escape_string, EscapeFlags, EscapeStringStyle},
|
||||||
fallback::fish_wcwidth,
|
fallback::fish_wcwidth,
|
||||||
reader::TERMINAL_MODE_ON_STARTUP,
|
reader::TERMINAL_MODE_ON_STARTUP,
|
||||||
wchar::prelude::*,
|
wchar::{decode_byte_from_char, prelude::*},
|
||||||
wutil::{fish_is_pua, fish_wcstoi},
|
wutil::{fish_is_pua, fish_wcstoi},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -453,6 +453,8 @@ pub fn char_to_symbol(c: char) -> WString {
|
||||||
} else if c < '\u{80}' {
|
} else if c < '\u{80}' {
|
||||||
// ASCII characters that are not control characters
|
// ASCII characters that are not control characters
|
||||||
ascii_printable_to_symbol(buf, c);
|
ascii_printable_to_symbol(buf, c);
|
||||||
|
} else if let Some(byte) = decode_byte_from_char(c) {
|
||||||
|
sprintf!(=> buf, "\\x%02x", byte);
|
||||||
} else if ('\u{e000}'..='\u{f8ff}').contains(&c) {
|
} else if ('\u{e000}'..='\u{f8ff}').contains(&c) {
|
||||||
// Unmapped key from https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions
|
// Unmapped key from https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions
|
||||||
sprintf!(=> buf, "\\u%04X", u32::from(c));
|
sprintf!(=> buf, "\\u%04X", u32::from(c));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user