From 956b7a52640e7d817963ea3a4093715d57efd7da Mon Sep 17 00:00:00 2001 From: Sean Cheren Date: Thu, 30 Nov 2023 16:03:47 -0600 Subject: [PATCH 1/2] Update miniz.h Set locale to UTF-8 on windows for opening unicode filepaths --- thirdparty/zip/miniz.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/thirdparty/zip/miniz.h b/thirdparty/zip/miniz.h index 0e269d1..6bed179 100644 --- a/thirdparty/zip/miniz.h +++ b/thirdparty/zip/miniz.h @@ -4045,8 +4045,20 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, #if defined(_MSC_VER) static FILE *mz_fopen(const char *pFilename, const char *pMode) { - FILE *pFile = NULL; + FILE *pFile; + setlocale(LC_CTYPE, "en_US.UTF-8"); + const char* tempLocale = setlocale(LC_CTYPE, NULL); + + if (tempLocale) { + setlocale(LC_CTYPE, "en_US.UTF-8"); + } + fopen_s(&pFile, pFilename, pMode); + + if (tempLocale) { + setlocale(LC_CTYPE, tempLocale); + } + return pFile; } static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream) { From 76646fdc6863f126703044302c999c63f851135f Mon Sep 17 00:00:00 2001 From: Sean Cheren Date: Thu, 30 Nov 2023 16:36:24 -0600 Subject: [PATCH 2/2] Update miniz.h Don't set locale before getting temp locale --- thirdparty/zip/miniz.h | 1 - 1 file changed, 1 deletion(-) diff --git a/thirdparty/zip/miniz.h b/thirdparty/zip/miniz.h index 6bed179..25f525c 100644 --- a/thirdparty/zip/miniz.h +++ b/thirdparty/zip/miniz.h @@ -4046,7 +4046,6 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, #if defined(_MSC_VER) static FILE *mz_fopen(const char *pFilename, const char *pMode) { FILE *pFile; - setlocale(LC_CTYPE, "en_US.UTF-8"); const char* tempLocale = setlocale(LC_CTYPE, NULL); if (tempLocale) {