diff options
-rw-r--r-- | src/cmd/fmt.rs | 2 | ||||
-rw-r--r-- | src/cmd/input.rs | 2 | ||||
-rw-r--r-- | src/config.rs | 10 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/cmd/fmt.rs b/src/cmd/fmt.rs index 3878408..c62c26b 100644 --- a/src/cmd/fmt.rs +++ b/src/cmd/fmt.rs @@ -65,7 +65,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> { wconfig = wconfig.quote_style(csv::QuoteStyle::Always); } if let Some(escape) = args.flag_escape { - wconfig = wconfig.escape(escape.as_byte()).double_quote(false); + wconfig = wconfig.escape(Some(escape.as_byte())).double_quote(false); } wconfig = wconfig.quote(args.flag_quote.as_byte()); diff --git a/src/cmd/input.rs b/src/cmd/input.rs index b4a62f5..c837171 100644 --- a/src/cmd/input.rs +++ b/src/cmd/input.rs @@ -47,7 +47,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> { let wconfig = Config::new(&args.flag_output); if let Some(escape) = args.flag_escape { - rconfig = rconfig.escape(escape.as_byte()).double_quote(false); + rconfig = rconfig.escape(Some(escape.as_byte())).double_quote(false); } if args.flag_no_quoting { rconfig = rconfig.quoting(false); diff --git a/src/config.rs b/src/config.rs index 0539bed..fc51fe0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -65,7 +65,7 @@ pub struct Config { quote: u8, quote_style: csv::QuoteStyle, double_quote: bool, - escape: u8, + escape: Option<u8>, quoting: bool, } @@ -96,7 +96,7 @@ impl Config { quote: b'"', quote_style: csv::QuoteStyle::Necessary, double_quote: true, - escape: b'\\', + escape: None, quoting: true, } } @@ -150,7 +150,7 @@ impl Config { self } - pub fn escape(mut self, escape: u8) -> Config { + pub fn escape(mut self, escape: Option<u8>) -> Config { self.escape = escape; self } @@ -285,7 +285,7 @@ impl Config { .has_headers(!self.no_headers) .quote(self.quote) .quoting(self.quoting) - .escape(Some(self.escape)) + .escape(self.escape) .from_reader(rdr) } @@ -304,7 +304,7 @@ impl Config { .quote(self.quote) .quote_style(self.quote_style) .double_quote(self.double_quote) - .escape(self.escape) + .escape(self.escape.unwrap_or(b'\\')) .buffer_capacity(32 * (1<<10)) .from_writer(wtr) } |