Browse Source

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.
pre-master-46
Holger Vogt 5 years ago
parent
commit
d2f6ad239f
  1. 11
      src/misc/util.c

11
src/misc/util.c

@ -266,6 +266,7 @@ ngdirname(const char *name)
FILE * FILE *
newfopen(const char *fn, const char* md) newfopen(const char *fn, const char* md)
{ {
FILE* fp;
if (fn == NULL) if (fn == NULL)
return NULL; return NULL;
wchar_t wfn[BSIZE_SP]; 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); fprintf(stderr, "%s could not be converted\n", fn);
return NULL; 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
#endif #endif

Loading…
Cancel
Save