Detect data with embedded zeros as binary also for ISO-8859

See issues #1772 and #1773
This commit is contained in:
mgrojo
2019-03-03 14:25:49 +01:00
parent bede43f76c
commit 4b5b5c6238

View File

@@ -17,10 +17,11 @@ bool isTextOnly(QByteArray data, const QString& encoding, bool quickTest)
if(startsWithBom(data))
return true;
// We can assume that the default encoding (UTF-8) cannot contain character zero.
// This has to be checked explicitly because toUnicode() is ignoring bytes beyond
// the zero.
if(encoding.isEmpty() && data.contains('\0'))
// We can assume that the default encoding (UTF-8) and all the ISO-8859
// cannot contain character zero.
// This has to be checked explicitly because toUnicode() is using zero as
// a terminator for these encodings.
if((encoding.isEmpty() || encoding.startsWith("ISO-8859")) && data.contains('\0'))
return false;
// Truncate to the first couple of bytes for quick testing