mirror of
https://github.com/aristocratos/btop.git
synced 2024-06-02 02:24:54 +12:00
Fixed: Additional NULL checks in UTF-8 detection
This commit is contained in:
parent
ee8109ec38
commit
5273a62856
11
src/btop.cpp
11
src/btop.cpp
|
@ -718,10 +718,11 @@ 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 (bool found = false; std::setlocale(LC_ALL, NULL) != NULL and not str_to_upper(s_replace((string)std::setlocale(LC_ALL, NULL), "-", "")).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, getenv("LANG"));
|
||||
if (std::setlocale(LC_ALL, getenv("LANG")) != NULL) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
setenv("LANG", "", 1);
|
||||
|
@ -729,8 +730,8 @@ int main(int argc, char **argv) {
|
|||
if (const auto loc = std::locale("").name(); not loc.empty()) {
|
||||
for (auto& l : ssplit(loc, ';')) {
|
||||
if (str_to_upper(s_replace(l, "-", "")).ends_with("UTF8")) {
|
||||
found = true;
|
||||
std::setlocale(LC_ALL, l.substr(l.find('=') + 1).c_str());
|
||||
if (std::setlocale(LC_ALL, l.substr(l.find('=') + 1).c_str()) != NULL)
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue