MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetLocalCode

Function GetLocalCode

src/os/unix/unix.cpp:100–113  ·  view source on GitHub ↗

* Try and try to decipher the current locale from environmental * variables. MacOSX is hardcoded, other OS's are dynamic. If no suitable * locale can be found, don't do any conversion "" */

Source from the content-addressed store, hash-verified

98 * locale can be found, don't do any conversion ""
99 */
100static std::string GetLocalCode()
101{
102#if defined(__APPLE__)
103 return "UTF-8-MAC";
104#else
105 /* Strip locale (eg en_US.UTF-8) to only have UTF-8 */
106 auto locale = GetCurrentLocale("LC_CTYPE");
107 if (!locale.has_value()) return "";
108 auto pos = locale->find('.');
109 if (pos == std::string_view::npos) return "";
110 locale.erase(0, pos + 1);
111 return locale;
112#endif
113}
114
115/**
116 * Convert between locales, which from and which to is set in the calling

Callers 2

OTTD2FSFunction · 0.85
FS2OTTDFunction · 0.85

Calls 3

GetCurrentLocaleFunction · 0.50
findMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected