mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use std::string for Windows' ISO code mangling
parent
a541b8217d
commit
b2a8d8aea4
|
@ -541,23 +541,21 @@ const char *GetCurrentLocale(const char *)
|
||||||
|
|
||||||
static WCHAR _cur_iso_locale[16] = L"";
|
static WCHAR _cur_iso_locale[16] = L"";
|
||||||
|
|
||||||
void Win32SetCurrentLocaleName(const char *iso_code)
|
void Win32SetCurrentLocaleName(std::string iso_code)
|
||||||
{
|
{
|
||||||
/* Convert the iso code into the format that windows expects. */
|
/* Convert the iso code into the format that windows expects. */
|
||||||
char iso[16];
|
if (iso_code == "zh_TW") {
|
||||||
if (strcmp(iso_code, "zh_TW") == 0) {
|
iso_code = "zh-Hant";
|
||||||
strecpy(iso, "zh-Hant", lastof(iso));
|
} else if (iso_code == "zh_CN") {
|
||||||
} else if (strcmp(iso_code, "zh_CN") == 0) {
|
iso_code = "zh-Hans";
|
||||||
strecpy(iso, "zh-Hans", lastof(iso));
|
|
||||||
} else {
|
} else {
|
||||||
/* Windows expects a '-' between language and country code, but we use a '_'. */
|
/* Windows expects a '-' between language and country code, but we use a '_'. */
|
||||||
strecpy(iso, iso_code, lastof(iso));
|
for (char &c : iso_code) {
|
||||||
for (char *c = iso; *c != '\0'; c++) {
|
if (c == '_') c = '-';
|
||||||
if (*c == '_') *c = '-';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, iso, -1, _cur_iso_locale, lengthof(_cur_iso_locale));
|
MultiByteToWideChar(CP_UTF8, 0, iso_code.c_str(), -1, _cur_iso_locale, lengthof(_cur_iso_locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
int OTTDStringCompare(std::string_view s1, std::string_view s2)
|
int OTTDStringCompare(std::string_view s1, std::string_view s2)
|
||||||
|
|
|
@ -1887,7 +1887,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang)
|
||||||
SetCurrentGrfLangID(_current_language->newgrflangid);
|
SetCurrentGrfLangID(_current_language->newgrflangid);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
extern void Win32SetCurrentLocaleName(const char *iso_code);
|
extern void Win32SetCurrentLocaleName(std::string iso_code);
|
||||||
Win32SetCurrentLocaleName(_current_language->isocode);
|
Win32SetCurrentLocaleName(_current_language->isocode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue