Commit e2a8cdd2 authored by Matus Uzak's avatar Matus Uzak
Browse files

Handle UTF-8/UTF-16 encoding when processing Document Information.

BUG:305440
parent 959ecb38
......@@ -29,7 +29,8 @@
*/
enum PropertyType
{
PIDSI_TITLE = 0x00000002,
PIDSI_CODEPAGE = 0x00000001,
PIDSI_TITLE,
PIDSI_SUBJECT,
PIDSI_AUTHOR,
PIDSI_KEYWORDS,
......
......@@ -228,6 +228,9 @@ void Document::processAssociatedStrings()
}
}
static const quint16 CP_WINUNICODE = 0x04B0;
bool isUnicode16 = false;
QString title;
QString subject;
QString keywords;
......@@ -241,6 +244,13 @@ void Document::processAssociatedStrings()
for (uint i = 0; i < ps.numProperties; i++) {
switch (ps.propertyIdentifierAndOffset.at(i).propertyIdentifier) {
case PIDSI_CODEPAGE:
if (ps.property.at(i)._has_vt_I2) {
if (ps.property.at(i).vt_I2 == CP_WINUNICODE) {
isUnicode16 = true;
}
}
break;
case PIDSI_TITLE:
p_str = &title;
break;
......@@ -264,7 +274,11 @@ void Document::processAssociatedStrings()
}
if (p_str) {
if (ps.property.at(i).vt_lpstr) {
*p_str = ps.property.at(i).vt_lpstr->characters;
if (isUnicode16) {
*p_str = QString::fromUtf16((ushort*)ps.property.at(i).vt_lpstr->characters.data());
} else {
*p_str = QString::fromUtf8(ps.property.at(i).vt_lpstr->characters.data());
}
}
p_str = 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment