[poppler] Utils - Fix UTF-16 file name on Windows environment

Martin (gzlist) gzlist at googlemail.com
Sun Jun 24 12:05:32 UTC 2018

On 19/06/2018, Albert Astals Cid <aacid at kde.org> wrote:
> It does make some sense given that function exists in the first place but my
> experience with windows is veeeeeeeeeeeeery limited so I'd like for someone
> else to vouch for this before landing it.

Overall the change might be, but there are some tricky aspects.

On windows fopen takes a narrow string of variable codepage, and
openFile takes (sort-of*) utf-8 but the types are not distinguished in
the codebase so it's tricky to see what callers are providing.

In cases where the string being used comes straight from say, the
command line or environment block, it will not be utf-8 so non-ascii
characters will be mangled. That's probably best fixed by ensuring on
GooString construction that it's converted to utf-8 but at present
that's entirely unvalidated.


 #ifdef VMS
-    f = fopen(fileName->getCString(), "rb", "ctx=stm");
+    f = openFile(fileName->getCString(), "rb", "ctx=stm");
-    f = fopen(fileName->getCString(), "rb");
+    f = openFile(fileName->getCString(), "rb");

Breaks compilation on VMS (if that's still a platform that matters) as
openFile takes two args only. Oddly, GooFile::open already includes
this logic but openFile does not. Can just drop the first branch
change for now.


*sort-of utf-8: gfile.cc has a pretty half-assed utf-8 to utf-16
conversion algorithm in several places that only correctly handles a
subset of inputs.

More information about the poppler mailing list