mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
UTF-8 support (PDF 2.0 compliance) and ProcedureSets (for compatibility)
This commit is contained in:
@ -2193,6 +2193,10 @@ QString PDFEncoding::convertTextString(const QByteArray& stream)
|
||||
{
|
||||
return convertFromUnicode(stream);
|
||||
}
|
||||
else if (hasUTF8LeadMarkings(stream))
|
||||
{
|
||||
return QString::fromUtf8(stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
return convert(stream, Encoding::PDFDoc);
|
||||
@ -2348,4 +2352,20 @@ bool PDFEncoding::hasUnicodeLeadMarkings(const QByteArray& stream)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PDFEncoding::hasUTF8LeadMarkings(const QByteArray& stream)
|
||||
{
|
||||
if (stream.size() >= 3)
|
||||
{
|
||||
if (static_cast<unsigned char>(stream[0]) == 239 &&
|
||||
static_cast<unsigned char>(stream[1]) == 187 &&
|
||||
static_cast<unsigned char>(stream[2]) == 191)
|
||||
{
|
||||
// UTF-8
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace pdf
|
||||
|
Reference in New Issue
Block a user