Skip to content

Commit

Permalink
data: remove control characters from ByteStr repr
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Mar 6, 2024
1 parent 23a7328 commit 0cf6df4
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/data/byte_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,8 @@ impl Display for ByteStr {
let mut ctl = false;
for c in s.chars() {
let v = c as u32;
if c.is_control() || v <= 0x21 || v >= 0x7F {
if (c.is_control() && v != 0x20) || v < 0x20 || v >= 0x7F {
if !ctl {
f.write_str("\x1B[2;3m<\x1B[1m")?;
ctl = true;
}
if v <= 0xFF {
Expand All @@ -235,15 +234,11 @@ impl Display for ByteStr {
}
} else {
if ctl {
f.write_str("\x1B[2m>\x1B[1;23m")?;
ctl = false;
}
f.write_char(c)?;
}
}
if ctl {
f.write_str("\x1B[2m>\x1B[1;23m")?;
}
f.write_str("\"")
} else {
f.write_str(&self.as_ref().to_hex())
Expand Down

0 comments on commit 0cf6df4

Please sign in to comment.