mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-10 20:40:40 +00:00
Inserted encoding information before locale variant. (Fix for bug #14492.)
This commit is contained in:
parent
b2a6f22992
commit
6855d5efb3
@ -147,33 +147,35 @@ static void wesnoth_setlocale(int category, std::string const &slocale,
|
||||
locale = win_locale;
|
||||
#endif
|
||||
|
||||
std::string extra;
|
||||
|
||||
char *res = NULL;
|
||||
std::vector<std::string>::const_iterator i;
|
||||
if (alternates) i = alternates->begin();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
std::string lang = locale, extra;
|
||||
std::string::size_type pos = locale.find('@');
|
||||
if (pos != std::string::npos) {
|
||||
lang.erase(pos);
|
||||
extra = locale.substr(pos);
|
||||
}
|
||||
|
||||
char const *encoding[] = { "", ".utf-8", ".UTF-8" };
|
||||
for (int j = 0; j != 3; ++j)
|
||||
{
|
||||
locale = lang + encoding[j] + extra;
|
||||
res = std::setlocale(category, locale.c_str());
|
||||
if (res) break;
|
||||
|
||||
std::string utf8 = locale + ".utf-8";
|
||||
res = std::setlocale(category, utf8.c_str());
|
||||
if (res) break;
|
||||
|
||||
utf8 = locale + ".UTF-8";
|
||||
res = std::setlocale(category, utf8.c_str());
|
||||
if (res) break;
|
||||
if (res) {
|
||||
LOG_G << "Set locale to '" << locale << "' result: '" << res << "'.\n";
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (!alternates || i == alternates->end()) break;
|
||||
locale = *i + extra;
|
||||
locale = *i;
|
||||
++i;
|
||||
}
|
||||
|
||||
if (res)
|
||||
LOG_G << "Set locale to '" << locale << "' result: '" << res <<"'.\n";
|
||||
else {
|
||||
WRN_G << "setlocale() failed for '" << slocale << "'.\n";
|
||||
#ifndef _WIN32
|
||||
#ifndef __AMIGAOS4__
|
||||
@ -184,8 +186,8 @@ static void wesnoth_setlocale(int category, std::string const &slocale,
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
done:
|
||||
DBG_G << "Numeric locale: " << std::setlocale(LC_NUMERIC, NULL) << '\n';
|
||||
DBG_G << "Full locale: " << std::setlocale(LC_ALL, NULL) << '\n';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user