From e9d77e5a8170802ad32ad7fbb585653828118a12 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 7 Mar 2022 23:51:22 -0500 Subject: [PATCH 1/2] Use encoding_rs_io for utf8 transcoding --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + 2 files changed, 11 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 19328ec16..9bcaad2ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1160,6 +1160,15 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "encoding_rs_io" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cc3c5651fb62ab8aa3103998dade57efdd028544bd300516baa31840c252a83" +dependencies = [ + "encoding_rs", +] + [[package]] name = "enum-as-inner" version = "0.3.4" @@ -2665,6 +2674,7 @@ dependencies = [ "csv-index", "dateparser", "docopt", + "encoding_rs_io", "eudex", "filetime", "flexi_logger", diff --git a/Cargo.toml b/Cargo.toml index b1816f467..2a66197f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,7 @@ csv = "1.1" csv-index = "0.1" dateparser = "0.1" docopt = "1" +encoding_rs_io = "0.1" eudex = { version = "0.1", optional = true } filetime = "0.2" flexi_logger = { version = "0.22", features = ["compress"] } From db9bb8aca76ad3bf44d6a5f433097e0dfbeb88be Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 7 Mar 2022 23:52:52 -0500 Subject: [PATCH 2/2] transcode to utf8 especially useful in Windows, as the default encoding in WIndows is UTF16-LE and qsv expects UTF8 --- src/config.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index c60ec130d..18e1362be 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,6 +5,7 @@ use std::io::{self, Read}; use std::ops::Deref; use std::path::PathBuf; +use encoding_rs_io::DecodeReaderBytes; use serde::de::{Deserialize, Deserializer, Error}; use crate::index::Indexed; @@ -298,7 +299,10 @@ impl Config { Ok(match self.path { None => Box::new(io::stdin()), Some(ref p) => match fs::File::open(p) { - Ok(x) => Box::new(x), + Ok(x) => { + let transcoded = DecodeReaderBytes::new(x); + Box::new(transcoded) + } Err(err) => { let msg = format!("failed to open {}: {}", p.display(), err); return Err(io::Error::new(io::ErrorKind::NotFound, msg));