Fixed: Check that getenv("LANG") is not NULL in UTF-8 check

This commit is contained in:
aristocratos 2021-09-22 19:32:00 +02:00
parent bc0c109e5e
commit 1f5aebead0

View File

@ -719,9 +719,9 @@ int main(int argc, char **argv) {
//? Try to find and set a UTF-8 locale
if (bool found = false; not str_to_upper(s_replace((string)std::setlocale(LC_ALL, NULL), "-", "")).ends_with("UTF8")) {
if (const string lang = (string)getenv("LANG"); str_to_upper(s_replace(lang, "-", "")).ends_with("UTF8")) {
if (getenv("LANG") != NULL and str_to_upper(s_replace((string)getenv("LANG"), "-", "")).ends_with("UTF8")) {
found = true;
std::setlocale(LC_ALL, lang.c_str());
std::setlocale(LC_ALL, getenv("LANG"));
}
else {
setenv("LANG", "", 1);