fix non-utf locale

This commit is contained in:
staviq 2023-10-20 04:03:22 +02:00
parent 5616b439df
commit 1e328f43f7

View file

@ -22,6 +22,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
#include <termios.h> #include <termios.h>
#include <string.h>
#endif #endif
#define ANSI_COLOR_RED "\x1b[31m" #define ANSI_COLOR_RED "\x1b[31m"
@ -115,7 +116,7 @@ namespace console {
auto lang = getenv("LANG"); auto lang = getenv("LANG");
if (locale == nullptr) { if (locale == nullptr) {
if (lang != nullptr) { if (lang != nullptr && strcmp(lang, "C") && strcasestr(lang, "utf-8")) {
setlocale(LC_ALL, lang); setlocale(LC_ALL, lang);
} else{ } else{
setlocale(LC_ALL, "C.UTF-8"); setlocale(LC_ALL, "C.UTF-8");