Potential wxLocale Windows issue

39 views
Skip to first unread message

Tobias T

unread,
Jun 10, 2021, 6:04:44 AM6/10/21
to wx-dev
Hi,
I'm not sure if this is a wxWidgets issue or a missunderstanding on my part, but here is the description of the issue I stumbled upon with a windows debug build:

The following assertion was triggered:
"Decimal separator mismatch -- did you use setlocale()?"
Source code here
This only happened on a computer with German regional settings (where decimal seperator is , instead of .)

In my app I use wxLocale::Init() without parameters which I assumed should be the equivalent of calling Init(wxLocale::GetSystemLanguage()) as it's documented.
But when using wxLANGUAGE_DEFAULT there are a few ifs in wxLocale::Init() that behave differently.
When using Init(wxLocale::GetSystemLanguage()) the assertion isn't triggered.

I doubt this is intentional behavior.

Regards,
Tobias

Ian McInerney

unread,
Jun 10, 2021, 6:45:36 AM6/10/21
to wx-...@googlegroups.com
Are you using the current master branch or 3.1.5? One user of a program I work on reported something similar can happen when the language settings are English and the regional setting are a comma-based locale. They think that https://github.com/wxWidgets/wxWidgets/commit/c9e2143a7a97ef82bcc20e8c6956663523a62adf will probably fix the issue, so it is possible that this is already fixed on the master branch.

-Ian

--
You received this message because you are subscribed to the Google Groups "wx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-dev/bb3c4232-d84c-4f2a-893a-cc1b483a96dcn%40googlegroups.com.


--
Ian McInerney
mcia...@gmail.com

No electrons were harmed in the making of this message

Tobias T

unread,
Jun 10, 2021, 10:18:12 AM6/10/21
to wx-dev
This on 3.1.5 will check if the changes in master, make a difference.

PB

unread,
Jun 10, 2021, 1:27:47 PM6/10/21
to wx-dev
Are you by any chance using mingw compiler toolchain? If so, this sound very similar (the same error message, happens with German locale) to what is in this thread: https://forums.wxwidgets.org/viewtopic.php?f=1&t=48266&p=206172&hilit=separator+locale#p205919
The issue there was incorrect linking of CRT libraries (to both old MSVCRT and UCRT).

Anyway, as said above, it would be interesting to know your exact locale info, you could use something like this
#include <wx/wx.h>
#include <wx/intl.h>

class MyApp : public wxApp
{
    wxLocale m_locale;
public:
    bool OnInit() override
    {
        m_locale.Init();

        wxChar threadDecimalSeparator[8]{0};
        wxChar userDefaultDecimalSeparator[8]{0};

        ::GetLocaleInfo(::GetThreadLocale(), LOCALE_SDECIMAL, threadDecimalSeparator, WXSIZEOF(threadDecimalSeparator));
        ::GetLocaleInfo(::GetUserDefaultLCID(), LOCALE_SDECIMAL, userDefaultDecimalSeparator, WXSIZEOF(userDefaultDecimalSeparator));

        wxLogMessage("Decimal separator for: \n  wxLocale = '%s'\n  Thread = '%s'\n  User default = '%s'",
            wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER), threadDecimalSeparator, userDefaultDecimalSeparator);

        return false;
    }
}; wxIMPLEMENT_APP(MyApp);

Vadim Zeitlin

unread,
Jun 10, 2021, 2:37:12 PM6/10/21
to wx-...@googlegroups.com
On Thu, 10 Jun 2021 10:27:47 -0700 (PDT) PB wrote:

P> Anyway, as said above, it would be interesting to know your exact locale
P> info, you could use something like this
[snip]

FWIW I've written a small program using Win32 API directly showing the
value of all (or some) locale options and I've just put it here if it can
be useful to anybody

https://gist.github.com/vadz/5827c77be02c3f7e928c03867ead13c4

It can be compiled using

cl /EHsc /W4 /std:c++latest /Os /MT winloc.cpp

command to produce a small statically linked executable.

Regards,
VZ
Reply all
Reply to author
Forward
0 new messages