[poppler] glib/poppler-document.cc

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Thu Jan 7 01:34:32 PST 2010


 glib/poppler-document.cc |   22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

New commits:
commit 526c8871cbdfbc119e013ee96887a79f65403790
Author: Hib Eris <hib at hiberis.nl>
Date:   Thu Dec 31 17:52:33 2009 +0100

    [glib] Use PDFDoc(wchar_t *, ...) on Windows
    
    Fixes bug #25032

diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index f461efb..cb6e485 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -161,9 +161,6 @@ poppler_document_new_from_file (const char  *uri,
   if (!filename)
     return NULL;
 
-  filename_g = new GooString (filename);
-  g_free (filename);
-
   password_g = NULL;
   if (password != NULL) {
     if (g_utf8_validate (password, -1, NULL)) {
@@ -180,7 +177,26 @@ poppler_document_new_from_file (const char  *uri,
     }
   }
 
+#ifdef G_OS_WIN32
+  wchar_t *filenameW;
+  int length;
+
+  length = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
+
+  filenameW = new WCHAR[length];
+  if (!filenameW)
+      return NULL;
+
+  length = MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, length);
+
+  newDoc = new PDFDoc(filenameW, length, password_g, password_g);
+  delete filenameW;
+#else
+  filename_g = new GooString (filename);
   newDoc = new PDFDoc(filename_g, password_g, password_g);
+#endif
+  g_free (filename);
+
   delete password_g;
 
   return _poppler_document_new_from_pdfdoc (newDoc, error);


More information about the poppler mailing list