summaryrefslogtreecommitdiffstats
path: root/src/worker.rs
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2018-07-21 20:36:32 -0400
committerAndrew Gallant <jamslam@gmail.com>2018-07-21 20:36:32 -0400
commit209a125ea25615e8fa605c844f8cbcca8c672208 (patch)
tree640f6abf39ad6cae599524bb529aa7fedd03c6c6 /src/worker.rs
parent090216cf002a579c987df76125fcdcb97478d48e (diff)
ripgrep: replace decoder with encoding_rs_io
This commit mostly moves the transcoder implementation to its own crate: https://github.com/BurntSushi/encoding_rs_io The new crate adds clear documentation and cleans up the implementation to fully implement the contract of io::Read.
Diffstat (limited to 'src/worker.rs')
-rw-r--r--src/worker.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/worker.rs b/src/worker.rs
index 5b7ef0a4..8e840400 100644
--- a/src/worker.rs
+++ b/src/worker.rs
@@ -8,7 +8,8 @@ use ignore::DirEntry;
use memmap::Mmap;
use termcolor::WriteColor;
-use decoder::DecodeReader;
+// use decoder::DecodeReader;
+use encoding_rs_io::DecodeReaderBytesBuilder;
use decompressor::{self, DecompressionReader};
use preprocessor::PreprocessorReader;
use pathutil::strip_prefix;
@@ -319,8 +320,10 @@ impl Worker {
path: &Path,
rdr: R,
) -> Result<u64> {
- let rdr = DecodeReader::new(
- rdr, &mut self.decodebuf, self.opts.encoding);
+ let rdr = DecodeReaderBytesBuilder::new()
+ .encoding(self.opts.encoding)
+ .utf8_passthru(true)
+ .build_with_buffer(rdr, &mut self.decodebuf)?;
let searcher = Searcher::new(
&mut self.inpbuf, printer, &self.grep, path, rdr);
searcher