B:BD[
6.159] → [
6.159:243]
B:BD[
5.407] → [
5.407:444]
B:BD[
5.444] → [
9.113:167]
B:BD[
6.342] → [
6.342:560]
B:BD[
6.560] → [
9.168:245]
B:BD[
6.636] → [
6.636:726]
B:BD[
6.726] → [
9.246:287]
B:BD[
6.788] → [
6.788:859]
B:BD[
6.859] → [
9.288:309]
B:BD[
6.891] → [
6.891:905]
let mut uncoded = Vec::new();
self.read_file(&file, &mut uncoded)?;
let mime = tree_magic::from_u8(&uncoded);
debug!("mime = {:?}", mime);
let encoding = if mime.starts_with("text/") {
let mut detector = EncodingDetector::new();
detector.feed(&uncoded, true);
let encoding = detector.guess(None, true);
debug!("guessed encoding = {:?}", encoding.name());
let (_decoded, encoding, malformed) = encoding.decode(&uncoded);
debug!("final encoding = {:?}", encoding.name());
if !malformed {
Some(Encoding(encoding))
} else {
warn!("text file was malformed");
None
}
let init = buffer.len();
self.read_file(&file, buffer)?;
let mut detector = EncodingDetector::new();
detector.feed(&buffer[init..], true);
let encoding = detector.guess(None, true);
let (_decoded, encoding, malformed) = encoding.decode(&buffer[init..]);
Ok(if !malformed {
Some(Encoding(encoding))