mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Fix glwprintf errors on OS X with non-ASCII strings, by setting LC_CTYPE to UTF-8
This was SVN commit r9768.
This commit is contained in:
parent
e9b3bcf467
commit
899f5105b9
2 changed files with 20 additions and 6 deletions
|
|
@ -675,10 +675,19 @@ void Shutdown(int UNUSED(flags))
|
|||
}
|
||||
|
||||
#if OS_UNIX
|
||||
void SetDefaultIfLocaleInvalid()
|
||||
static void FixLocales()
|
||||
{
|
||||
#if OS_MACOSX
|
||||
// OS X requires a UTF-8 locale in LC_CTYPE so that *wprintf can handle
|
||||
// wide characters. Peculiarly the string "UTF-8" seems to be acceptable
|
||||
// despite not being a real locale, and it's conveniently language-agnostic,
|
||||
// so use that.
|
||||
setlocale(LC_CTYPE, "UTF-8");
|
||||
#endif
|
||||
|
||||
|
||||
// On misconfigured systems with incorrect locale settings, we'll die
|
||||
// with a C++ exception when some code tries to use locales.
|
||||
// with a C++ exception when some code (e.g. Boost) tries to use locales.
|
||||
// To avoid death, we'll detect the problem here and warn the user and
|
||||
// reset to the default C locale.
|
||||
|
||||
|
|
@ -723,7 +732,7 @@ void SetDefaultIfLocaleInvalid()
|
|||
}
|
||||
}
|
||||
#else
|
||||
void SetDefaultIfLocaleInvalid()
|
||||
static void FixLocales()
|
||||
{
|
||||
// Do nothing on Windows
|
||||
}
|
||||
|
|
@ -744,7 +753,7 @@ void EarlyInit()
|
|||
|
||||
timer_LatchStartTime();
|
||||
|
||||
SetDefaultIfLocaleInvalid();
|
||||
FixLocales();
|
||||
|
||||
// Because we do GL calls from a secondary thread, Xlib needs to
|
||||
// be told to support multiple threads safely.
|
||||
|
|
|
|||
|
|
@ -65,20 +65,25 @@ class LeakReporter : public CxxTest::GlobalFixture
|
|||
|
||||
};
|
||||
|
||||
class TimerSetup : public CxxTest::GlobalFixture
|
||||
class MiscSetup : public CxxTest::GlobalFixture
|
||||
{
|
||||
virtual bool setUpWorld()
|
||||
{
|
||||
// Timer must be initialised, else things will break when tests do IO
|
||||
timer_LatchStartTime();
|
||||
|
||||
#if OS_MACOSX
|
||||
// See comment in GameSetup.cpp FixLocales
|
||||
setlocale(LC_CTYPE, "UTF-8");
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static LeakReporter leakReporter;
|
||||
static TimerSetup timerSetup;
|
||||
static MiscSetup miscSetup;
|
||||
|
||||
// Definition of functions from lib/self_test.h
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue