Re: [Celestia-developers] Crash on non-default LANG/LC_ALL and std::locale()
Real-time 3D visualization of space
Status: Beta
Brought to you by:
cjlaurel
From: Da W. J. <dir...@gm...> - 2006-01-19 23:52:08
|
Thanks for the suggestion - I placed a single setlocale(LC_ALL, ""); in my OS X's main() and it seems to prevent locale("") from crashing (is this documented anywhere? :-( So patching celestiacore.cpp is not necessary. However, it only prevents crashing - versions of OS X earlier than 10.4 seem to ignore the locale and numbers are always rendered without thousand separators, etc. Also the user still has to set LANG/LC_* manually. Perhaps a long term goal should be: make renderOverlay() overridable using platform-specific code (currently the method is private... what a bummer). This could allow better Unicode font support for example, without forcing CJK users to resort to huge font textures. Cheers, DW 2006/1/20, Pat Suwalski wrote: > Da Woon Jung wrote: > > This patch seems to stop locale() related crashes on OS X. It's more > > of a bandaid than a proper patch - OS X does not seem to change LANG > > or LC_* when the system language is switched, and locales are usually > > detected and changed via OS X platform-specific api calls which do not > > seem to be compatible with C++. I left the setlocale() calls in > > because on some recent versions of OS X, setlocale() apparently > > modifies the C++ locale too. > > I don't see how locales could be broken like that. Lots of projects use > them. It is possible there is some missing locale initialization or > something that is specific to osx? In GTK's main() I have: > > /* Force number displays into C locale. */ > setlocale(LC_NUMERIC, "C"); > setlocale(LC_ALL, ""); |