fix(unicode): add support for more unicode characters (#470)

This commit is contained in:
Alexandre Pasmantier 2025-04-18 12:11:13 +00:00 committed by GitHub
parent 315a9f71fa
commit 2be2ae7cde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -195,6 +195,9 @@ const ALL_NF_RANGES: [&std::ops::RangeInclusive<char>; 10] = [
&NF_RANGE_POWERLINE_2,
];
const VARIOUS_UNIT_WIDTH_SYMBOLS_RANGE: std::ops::RangeInclusive<char> =
'\u{2000}'..='\u{25FF}';
pub struct ReplaceNonPrintableConfig {
pub replace_tab: bool,
pub tab_width: usize,
@ -330,6 +333,10 @@ pub fn replace_non_printable(
c if ALL_NF_RANGES.iter().any(|r| r.contains(&c)) => {
output.push(c);
}
// Other unit width symbols
c if VARIOUS_UNIT_WIDTH_SYMBOLS_RANGE.contains(&c) => {
output.push(c);
}
// Unicode characters above 0x0700 seem unstable with ratatui
c if c > '\u{0700}' => {
output.push(NULL_SYMBOL);