michaelrsweet / pdfio

PDFio is a simple C library for reading and writing PDF files.
https://www.msweet.org/pdfio
Apache License 2.0
197 stars 44 forks source link

Non English letters in File paths will fail on Windows #18

Open gabrielaexile opened 3 years ago

gabrielaexile commented 3 years ago

Non English letters will fail in File paths for Windows _open cannot carry UTF8 on Windows.

Only solution I know is to use:

ifdef _WIN32

if ((fd = _wopen((const wchar_t*)filename, O_RDONLY | O_BINARY)) < 0)

else

if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0)

endif

Or alternative if you want to keep your API using UTF8 then take it in as UTF8 and convert to UTF16 before calling _wopen.

gabrielaexile commented 3 years ago

Example file path would be like if Windows user name is Þórunn then you cannot save the PDF in My Documents.

michaelrsweet commented 3 years ago

Sigh, I hate Windows... For now I will just document the issue until I can write a proper wrapper function.