[poppler] qt4/src qt5/src
Albert Astals Cid
aacid at kemper.freedesktop.org
Sun Mar 15 06:07:14 PDT 2015
qt4/src/poppler-private.cc | 36 +++++++++++++++---------------------
qt5/src/poppler-private.cc | 36 +++++++++++++++---------------------
2 files changed, 30 insertions(+), 42 deletions(-)
New commits:
commit 033dbbd7fef8c04c7f4961455cc1cd8d6d1bd93b
Author: Albert Astals Cid <aacid at kde.org>
Date: Sun Mar 15 14:06:15 2015 +0100
Fix the previous pdfDocEncoding fix
Since actually the previous fix didn't account for non ascii characters as output of pdfDocEncoding
diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index bef72f0..cbf21b1 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -101,36 +101,30 @@ namespace Debug {
if ( !s1 || s1->getLength() == 0 )
return QString();
- GBool isUnicode;
- int i;
- Unicode u;
- QString result;
+ char *cString;
+ int stringLength;
+ bool deleteCString;
if ( ( s1->getChar(0) & 0xff ) == 0xfe && ( s1->getLength() > 1 && ( s1->getChar(1) & 0xff ) == 0xff ) )
{
- isUnicode = gTrue;
- i = 2;
- result.reserve( ( s1->getLength() - 2 ) / 2 );
+ cString = s1->getCString();
+ stringLength = s1->getLength();
+ deleteCString = false;
}
else
{
- isUnicode = gFalse;
- i = 0;
- result.reserve( s1->getLength() );
+ cString = pdfDocEncodingToUTF16(s1, &stringLength);
+ deleteCString = true;
}
- while ( i < s1->getLength() )
+
+ QString result;
+ // i = 2 to skip the unicode marker
+ for ( int i = 2; i < stringLength; i += 2 )
{
- if ( isUnicode )
- {
- u = ( ( s1->getChar(i) & 0xff ) << 8 ) | ( s1->getChar(i+1) & 0xff );
- i += 2;
- }
- else
- {
- u = pdfDocEncoding[s1->getChar(i) & 0xff];
- ++i;
- }
+ const Unicode u = ( ( cString[i] & 0xff ) << 8 ) | ( cString[i+1] & 0xff );
result += QChar( u );
}
+ if (deleteCString)
+ delete[] cString;
return result;
}
diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc
index 8ede957..51395a2 100644
--- a/qt5/src/poppler-private.cc
+++ b/qt5/src/poppler-private.cc
@@ -101,36 +101,30 @@ namespace Debug {
if ( !s1 || s1->getLength() == 0 )
return QString();
- GBool isUnicode;
- int i;
- Unicode u;
- QString result;
+ char *cString;
+ int stringLength;
+ bool deleteCString;
if ( ( s1->getChar(0) & 0xff ) == 0xfe && ( s1->getLength() > 1 && ( s1->getChar(1) & 0xff ) == 0xff ) )
{
- isUnicode = gTrue;
- i = 2;
- result.reserve( ( s1->getLength() - 2 ) / 2 );
+ cString = s1->getCString();
+ stringLength = s1->getLength();
+ deleteCString = false;
}
else
{
- isUnicode = gFalse;
- i = 0;
- result.reserve( s1->getLength() );
+ cString = pdfDocEncodingToUTF16(s1, &stringLength);
+ deleteCString = true;
}
- while ( i < s1->getLength() )
+
+ QString result;
+ // i = 2 to skip the unicode marker
+ for ( int i = 2; i < stringLength; i += 2 )
{
- if ( isUnicode )
- {
- u = ( ( s1->getChar(i) & 0xff ) << 8 ) | ( s1->getChar(i+1) & 0xff );
- i += 2;
- }
- else
- {
- u = pdfDocEncoding[s1->getChar(i) & 0xff];
- ++i;
- }
+ const Unicode u = ( ( cString[i] & 0xff ) << 8 ) | ( cString[i+1] & 0xff );
result += QChar( u );
}
+ if (deleteCString)
+ delete[] cString;
return result;
}
More information about the poppler
mailing list