commit 4bea5b9d18af249661e23c462fea3f59042bac03
Author: Georg Baum <[email protected]>
Date: Sat Jun 7 17:48:23 2014 +0200
Explain why the binary detection works
Extracted from Enricos comment at bug 9146.
diff --git a/src/Format.cpp b/src/Format.cpp
index ff7fb34..44e3f63 100644
--- a/src/Format.cpp
+++ b/src/Format.cpp
@@ -379,6 +379,12 @@ string guessFormatFromContents(FileName const & fn)
maybelatex = true;
}
+ // Note that this is formally not correct, since count_bin_chars
+ // expects utf8, and str can be anything: plain text in any
+ // encoding, or really binary data. In practice it works, since
+ // QString::fromUtf8() drops invalid utf8 sequences, and while
+ // the exact number may not be correct, we still get a high
+ // number for truly binary files.
binchars += count_bin_chars(str);
}