wxLocale equivalent of _configthreadlocale(_ENABLE_PER_THREAD_LOCALE)

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
JOHI
Knows some wx things
Knows some wx things
Posts: 34
Joined: Fri Jul 20, 2018 8:25 pm

wxLocale equivalent of _configthreadlocale(_ENABLE_PER_THREAD_LOCALE)

Post by JOHI »

Hello,

I have read quite a lot of threads and documentation about wxLocale, but it remains a subject that still remains unclear.

So here is what i want to do: some of my threads including the main gui thread need to use the current locale (to use the proper decimal separator). Solution: create a wxLocale member in the APP, call Init and you are done!

But: some of my threads that generate XML need to used the "C' locale and not the 'APP' one.

Question: how do I do it using wxWidgets.
C: code _configthreadlocale(_ENABLE_PER_THREAD_LOCALE), set current locale and done.

How is this done with wxLocale? Can you specify to wxString::Printf() which locale to use? Can you do a per thread setting?

Thanks for any support,
Johi.
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxLocale equivalent of _configthreadlocale(_ENABLE_PER_THREAD_LOCALE)

Post by doublemax »

Under Windows ::SetThreadLocale() is called to set the locale, so creating another wxLocale instance in the thread should work. But for the other platforms, i don't see any equivalent code in <wxdir>/src/common/intl.cpp

If it's only for number conversions, there are a few helper functions in wxString that might help, e.g.
wxString::ToCDouble
https://docs.wxwidgets.org/trunk/classw ... 74f1f2b733
wxString::FromCDouble
https://docs.wxwidgets.org/trunk/classw ... 79dcaa2add
Use the source, Luke!
JOHI
Knows some wx things
Knows some wx things
Posts: 34
Joined: Fri Jul 20, 2018 8:25 pm

Re: wxLocale equivalent of _configthreadlocale(_ENABLE_PER_THREAD_LOCALE)

Post by JOHI »

Thank you very much for the info.
I created a local wxLocale object to do what needs to be done and it worked properly.
Best Regards,
Johi.
Post Reply