From 17795cdd61874c50100e8da9ac260c119edd41cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Tschumperl=C3=A9?= <david.tschumperle@gmail.com> Date: Tue, 2 Oct 2018 10:22:30 +0200 Subject: [PATCH] . --- CImg.h | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/CImg.h b/CImg.h index 66d06e7..9b408c7 100644 --- a/CImg.h +++ b/CImg.h @@ -6172,27 +6172,8 @@ namespace cimg_library_suffixed { } // Open a file (similar to std:: fopen(), but with wide character support on Windows). - inline std::FILE *std_fopen(const char *const path, const char *const mode) { - std::FILE *const res = std::fopen(path,mode); - if (res) return res; -#if cimg_OS==2 - // Try alternative method, with wide-character string. - int err = MultiByteToWideChar(CP_UTF8,0,path,-1,0,0); - if (err) { - CImg<wchar_t> wpath(err); - err = MultiByteToWideChar(CP_UTF8,0,path,-1,wpath,err); - if (err) { // Convert 'mode' to a wide-character string. - err = MultiByteToWideChar(CP_UTF8,0,mode,-1,0,0); - if (err) { - CImg<wchar_t> wmode(err); - if (MultiByteToWideChar(CP_UTF8,0,mode,-1,wmode,err)) - return _wfopen(wpath,wmode); - } - } - } -#endif - return 0; - } + inline std::FILE *std_fopen(const char *const path, const char *const mode); + //! Open a file. /** @@ -59827,6 +59808,29 @@ namespace cimg { #endif } + // Open a file (similar to std:: fopen(), but with wide character support on Windows). + inline std::FILE *std_fopen(const char *const path, const char *const mode) { + std::FILE *const res = std::fopen(path,mode); + if (res) return res; +#if cimg_OS==2 + // Try alternative method, with wide-character string. + int err = MultiByteToWideChar(CP_UTF8,0,path,-1,0,0); + if (err) { + CImg<wchar_t> wpath(err); + err = MultiByteToWideChar(CP_UTF8,0,path,-1,wpath,err); + if (err) { // Convert 'mode' to a wide-character string. + err = MultiByteToWideChar(CP_UTF8,0,mode,-1,0,0); + if (err) { + CImg<wchar_t> wmode(err); + if (MultiByteToWideChar(CP_UTF8,0,mode,-1,wmode,err)) + return _wfopen(wpath,wmode); + } + } + } +#endif + return 0; + } + //! Get/set path to store temporary files. /** \param user_path Specified path, or \c 0 to get the path currently used. -- GitLab