1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-09 06:42:26 +01:00

Print non-printable characters using caret notation (#2443)

When the new flag is set, non-printable characters are printed using caret notation.
This commit is contained in:
einfachIrgendwer0815
2023-03-14 22:21:30 +01:00
committed by GitHub
parent c5602f9766
commit 8f99a78cf1
11 changed files with 151 additions and 37 deletions

View File

@@ -93,7 +93,11 @@ impl<'a> Printer for SimplePrinter<'a> {
) -> Result<()> {
if !out_of_range {
if self.config.show_nonprintable {
let line = replace_nonprintable(line_buffer, self.config.tab_width);
let line = replace_nonprintable(
line_buffer,
self.config.tab_width,
self.config.nonprintable_notation,
);
write!(handle, "{}", line)?;
} else {
handle.write_all(line_buffer)?
@@ -422,7 +426,11 @@ impl<'a> Printer for InteractivePrinter<'a> {
line_buffer: &[u8],
) -> Result<()> {
let line = if self.config.show_nonprintable {
replace_nonprintable(line_buffer, self.config.tab_width)
replace_nonprintable(
line_buffer,
self.config.tab_width,
self.config.nonprintable_notation,
)
} else {
let line = match self.content_type {
Some(ContentType::BINARY) | None => {