]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
mtmd, arg: fix utf8 handling on windows (llama/24779)
authorXuan-Son Nguyen <redacted>
Fri, 19 Jun 2026 20:28:38 +0000 (22:28 +0200)
committerGeorgi Gerganov <redacted>
Fri, 26 Jun 2026 13:03:57 +0000 (16:03 +0300)
* mtmd, arg: fix utf8 handling on windows

* also fix ggml_fopen

* fix build fail

* also fix CLI

ggml/src/ggml.c

index b43016c87d21a4ebf505f729c7a09d5ff97619fa..0f682fd1856c55fb1c94f6ec1f18262382fc277b 100644 (file)
@@ -600,18 +600,15 @@ FILE * ggml_fopen(const char * fname, const char * mode) {
     // convert fname (UTF-8)
     wchar_t * wfname = ggml_mbstowcs(fname);
     if (wfname) {
-        // convert mode (ANSI)
-        wchar_t * wmode = GGML_MALLOC((strlen(mode) + 1) * sizeof(wchar_t));
-        wchar_t * wmode_p = wmode;
-        do {
-            *wmode_p++ = (wchar_t)*mode;
-        } while (*mode++);
-
-        // open file
-        file = _wfopen(wfname, wmode);
+        // convert mode (UTF-8)
+        wchar_t * wmode = ggml_mbstowcs(mode);
+        if (wmode) {
+            // open file
+            file = _wfopen(wfname, wmode);
+            GGML_FREE(wmode);
+        }
 
         GGML_FREE(wfname);
-        GGML_FREE(wmode);
     }
 
     return file;