Global: better handling locales

This commit is contained in:
Carter Li
2024-06-07 10:00:30 +08:00
parent 896468195a
commit 5df5bbf85b
3 changed files with 14 additions and 10 deletions
+8 -1
View File
@@ -8,9 +8,9 @@
#include <stdlib.h>
#include <unistd.h>
#include <locale.h>
#ifdef _WIN32
#include <windows.h>
#include <locale.h>
#include "util/windows/unicode.h"
#else
#include <signal.h>
@@ -51,6 +51,13 @@ void ffInitInstance(void)
#ifdef WIN32
//https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?source=recommendations&view=msvc-170#utf-8-support
setlocale(LC_ALL, ".UTF8");
#else
// Never use `setlocale(LC_ALL, "")`
setlocale(LC_TIME, "");
setlocale(LC_NUMERIC, "");
#ifdef LC_MESSAGES
setlocale(LC_MESSAGES, "");
#endif
#endif
initState(&instance.state);