From d2f6ad239f10372ca80c54b307d146f6b4598cc4 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 17 Apr 2021 18:19:39 +0200 Subject: [PATCH] If the input file path contains ANSI-encoded special characters, utf-8 conversion and thus file opening will fail. This patch then in addition tries opening the file with standard fopen. --- src/misc/util.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/misc/util.c b/src/misc/util.c index d438337ff..0542c35fb 100644 --- a/src/misc/util.c +++ b/src/misc/util.c @@ -266,6 +266,7 @@ ngdirname(const char *name) FILE * newfopen(const char *fn, const char* md) { + FILE* fp; if (fn == NULL) return NULL; wchar_t wfn[BSIZE_SP]; @@ -276,7 +277,15 @@ newfopen(const char *fn, const char* md) fprintf(stderr, "%s could not be converted\n", fn); return NULL; } - return _wfopen(wfn, wmd); + fp = _wfopen(wfn, wmd); + +/* If wide char fails, at least fopen may try the potentially ANSI encoded special characters like á */ +#undef fopen + if (fp == NULL) + fp = fopen(fn, md); +#define fopen newfopen + + return fp; } #endif #endif