Bugfix: Enable UTF-16 LE strings

This commit is contained in:
Jakub Melka 2020-07-10 18:36:38 +02:00
parent 7acc8da51b
commit 1ef7d08d47
1 changed files with 15 additions and 1 deletions

View File

@ -2331,7 +2331,21 @@ const encoding::EncodingTable* PDFEncoding::getTableForEncoding(Encoding encodin
bool PDFEncoding::hasUnicodeLeadMarkings(const QByteArray& stream)
{
return (stream.size() >= 2 && static_cast<unsigned char>(stream[0]) == 0xFE && static_cast<unsigned char>(stream[1]) == 0xFF);
if (stream.size() >= 2)
{
if (static_cast<unsigned char>(stream[0]) == 0xFE && static_cast<unsigned char>(stream[1]) == 0xFF)
{
// UTF 16-BE
return true;
}
if (static_cast<unsigned char>(stream[0]) == 0xFF && static_cast<unsigned char>(stream[1]) == 0xFE)
{
// UTF 16-LE, forbidden in PDF 2.0 standard, but used in some PDF producers (wrongly)
return true;
}
}
return false;
}
} // namespace pdf