void * fz_fopen_utf8(const char *name, const char *mode) { wchar_t *wname, *wmode; FILE *file; wname = fz_wchar_from_utf8(name); if (wname == NULL) { return NULL; } wmode = fz_wchar_from_utf8(mode); if (wmode == NULL) { free(wname); return NULL; } file = _wfopen(wname, wmode); free(wname); free(wmode); return file; }
FILE * fz_fopen_utf8(const char *name, const char *mode) { wchar_t *wname, *wmode; FILE *file; /* SumatraPDF: prefer ANSI to UTF-8 for reading for consistency with remaining API */ #undef fopen if (strchr(mode, 'r') && (file = fopen(name, mode)) != NULL) return file; wname = fz_wchar_from_utf8(name); if (wname == NULL) { return NULL; } wmode = fz_wchar_from_utf8(mode); if (wmode == NULL) { free(wname); return NULL; } file = _wfopen(wname, wmode); free(wname); free(wmode); return file; }
int fz_remove_utf8(const char *name) { wchar_t *wname; int n; wname = fz_wchar_from_utf8(name); if (wname == NULL) { errno = ENOMEM; return -1; } n = _wremove(wname); free(wname); return n; }