From 1fe8c0f00028a022373be3c7a0bd3ee95f2c9327 Mon Sep 17 00:00:00 2001 From: Hib Eris Date: Thu, 31 Dec 2009 17:52:33 +0100 Subject: [PATCH] [glib] Use PDFDoc(wchar_t *, ...) on Windows fixes bfo#25032 --- glib/poppler-document.cc | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) 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); -- 1.6.0.4