fix non-utf locale
This commit is contained in:
parent
5616b439df
commit
1e328f43f7
1 changed files with 2 additions and 1 deletions
|
@ -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");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue