utils: add locale_workaround
Attempt to work around some locale handling throwing in some systems. "locale::facet::_S_create_c_locale name not valid" Ugly, but maybe it helps.
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
|
||||
#ifndef _XOPEN_SOURCE
|
||||
#define _XOPEN_SOURCE
|
||||
#include <stdexcept>
|
||||
#endif /*_XOPEN_SOURCE*/
|
||||
|
||||
#include <array>
|
||||
@ -606,3 +607,21 @@ Mu::TempDir::~TempDir()
|
||||
|
||||
g_debug("removed '%s'", path_.c_str());
|
||||
}
|
||||
|
||||
bool
|
||||
Mu::locale_workaround()
|
||||
{
|
||||
// quite horrible... but some systems break otherwise with
|
||||
// https://github.com/djcb/mu/issues/2252
|
||||
|
||||
for (auto&& loc : {"", "en_US.UTF-8", "C" }) {
|
||||
try {
|
||||
std::locale::global(std::locale(loc));
|
||||
return true;
|
||||
} catch (const std::runtime_error& re) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user