From e44bec15b8c064bf8f5ba0a79a2b650c996ef659 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Wed, 11 Nov 2009 16:07:25 +0100 Subject: [PATCH] [glib] Fix loading of files with non-ascci characters in path on win32 --- glib/poppler-document.cc | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index e5b2854..2fda5c4 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -149,21 +149,26 @@ poppler_document_new_from_file (const char *uri, GError **error) { PDFDoc *newDoc; +#ifdef G_OS_WIN32 + wchar_t *filename; +#else GooString *filename_g; - GooString *password_g; char *filename; +#endif + GooString *password_g; if (!globalParams) { globalParams = new GlobalParams(); } +#ifdef G_OS_WIN32 + filename = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL); +#else filename = g_filename_from_uri (uri, NULL, error); +#endif 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 +185,13 @@ poppler_document_new_from_file (const char *uri, } } +#ifdef G_OS_WIN32 + newDoc = new PDFDoc(filename, password_g, password_g); +#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.3.3