Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

Support unicode characters in model path (#3681)

Jeffrey Morgan7c9792a6e0f7
diff --git a/llm/ext_server/server.cpp b/llm/ext_server/server.cpp
index f5d7863d3..221170376 100644
--- a/llm/ext_server/server.cpp
+++ b/llm/ext_server/server.cpp
@@ -39,6 +39,10 @@
#include "httplib.h"
#include "json.hpp"
+#if defined(_WIN32)
+#include <windows.h>
+#endif
+
#include <cstddef>
#include <thread>
#include <chrono>
@@ -2770,8 +2774,28 @@ inline void signal_handler(int signal) {
shutdown_handler(signal);
}
-int main(int argc, char **argv)
-{
+#if defined(_WIN32)
+char* wchar_to_char(const wchar_t* wstr) {
+ if (wstr == nullptr) return nullptr;
+
+ // Determine the number of bytes needed for the UTF-8 string
+ int bytes = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
+ char* str = new char[bytes];
+
+ // Convert the wide-character string to a UTF-8 string
+ WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, bytes, nullptr, nullptr);
+ return str;
+}
+
+int wmain(int argc, wchar_t **wargv) {
+ char** argv = new char*[argc];
+ for (int i = 0; i < argc; ++i) {
+ argv[i] = wchar_to_char(wargv[i]);
+ }
+#else
+int main(int argc, char **argv) {
+#endif
+
#if SERVER_VERBOSE != 1
log_disable();
#endif
@@ -3282,6 +3306,11 @@ int main(int argc, char **argv)
return (ctrl_type == CTRL_C_EVENT) ? (signal_handler(SIGINT), true) : false;
};
SetConsoleCtrlHandler(reinterpret_cast<PHANDLER_ROUTINE>(console_ctrl_handler), true);
+
+ for (int i = 0; i < argc; ++i) {
+ delete[] argv[i];
+ }
+ delete[] argv;
#endif
llama.queue_tasks.start_loop();
svr.stop();