1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-12 00:02:28 +01:00

Allow for non-unicode filenames, closes #225

This commit is contained in:
sharkdp
2020-02-12 23:23:49 +01:00
committed by David Peter
parent e98f34b1e8
commit 7779d9f622
6 changed files with 16 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
use std::io::Write;
use std::vec::Vec;
use std::borrow::Cow;
use ansi_term::Colour::{Fixed, Green, Red, Yellow};
use ansi_term::Style;
@@ -225,7 +226,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
if !self.config.output_components.header() {
if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
let input = match file {
InputFile::Ordinary(filename) => format!("file '{}'", filename),
InputFile::Ordinary(filename) => format!("file '{}'", filename.to_string_lossy()),
_ => "STDIN".into(),
};
@@ -261,8 +262,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
}
let (prefix, name) = match file {
InputFile::Ordinary(filename) => ("File: ", filename),
_ => ("", "STDIN"),
InputFile::Ordinary(filename) => ("File: ", filename.to_string_lossy()),
_ => ("", Cow::from("STDIN")),
};
let mode = match self.content_type {