[poppler] cpp/poppler-global.cpp cpp/poppler-private.cpp

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Dec 7 14:52:57 UTC 2018


 cpp/poppler-global.cpp  |   12 ++++++++++--
 cpp/poppler-private.cpp |    2 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 135e897ed9a550361eb8f07a5ffedec48f079bd9
Author: Suzuki Toshiya <mpsuzuki at hiroshima-u.ac.jp>
Date:   Fri Dec 7 09:21:42 2018 +0100

    Improve handling of UTF-16 in cpp frontend by considering Endianess

diff --git a/cpp/poppler-global.cpp b/cpp/poppler-global.cpp
index cc51e3d3..d84554a5 100644
--- a/cpp/poppler-global.cpp
+++ b/cpp/poppler-global.cpp
@@ -226,7 +226,11 @@ byte_array ustring::to_utf8() const
         return byte_array();
     }
 
-    MiniIconv ic("UTF-8", "UTF-16");
+#ifdef WORDS_BIGENDIAN
+    MiniIconv ic("UTF-8", "UTF-16BE");
+#else
+    MiniIconv ic("UTF-8", "UTF-16LE");
+#endif
     if (!ic.is_valid()) {
         return byte_array();
     }
@@ -274,7 +278,11 @@ ustring ustring::from_utf8(const char *str, int len)
         }
     }
 
-    MiniIconv ic("UTF-16", "UTF-8");
+#ifdef WORDS_BIGENDIAN
+    MiniIconv ic("UTF-16BE", "UTF-8");
+#else
+    MiniIconv ic("UTF-16LE", "UTF-8");
+#endif
     if (!ic.is_valid()) {
         return ustring();
     }
diff --git a/cpp/poppler-private.cpp b/cpp/poppler-private.cpp
index 8125da2b..04ac32c2 100644
--- a/cpp/poppler-private.cpp
+++ b/cpp/poppler-private.cpp
@@ -93,7 +93,7 @@ ustring detail::unicode_GooString_to_ustring(const GooString *str)
 
 ustring detail::unicode_to_ustring(const Unicode *u, int length)
 {
-    ustring str(length * 2, 0);
+    ustring str(length, 0);
     ustring::iterator it = str.begin();
     const Unicode *uu = u;
     for (int i = 0; i < length; ++i) {


More information about the poppler mailing list