Opened 5 years ago

Closed 5 years ago

#14918 closed defect (fixed)

Fix locale mismatch between CRT and Windows functions in wxMSW

Reported by: vadz Owned by:
Priority: normal Milestone: 2.9.5
Component: wxMSW Version:
Keywords: locale wxDateTime Cc:
Blocked By: Blocking:
Patch: no


As explained in the first message of this thread, there is a mismatch between the locale used by the CRT functions such as strftime(), used by wxDateTime::Format(), and Windows functions such as GetLocaleInfo(), used by wxDateTime::Parse(), resulting in incompatibility between these 2 functions.

I don't see any good solution for this but changing Windows locale to match the CRT one seems less bad than using Windows locale by default (whether via CRT or not).

Change History (2)

comment:1 Changed 5 years ago by VZ

(In [73244]) Add a temporary workaround to make the tests pass.

Call SetCLocale() on tests startup to avoid problems with wxDateTime parsing
that happen when the user locale is different from "C" one under Windows.

See #14918.

comment:2 Changed 5 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [73320]) Fix wxLocale::GetInfo() in C locale under Windows.

Don't use LOCALE_USER_DEFAULT when the locale hadn't been changed because the
user default locale often (and maybe even always) is different from "C" locale
used by the CRT resulting in mismatch between the conventions used by
wxDateTime::Format(), which uses the CRT locale, and wxDateTime::Parse(),
which uses Windows format. Instead use the hard-coded values corresponding to
the "C" locale to ensure we use the same values as the CRT in this case.

This also reverts r73244 which was applies to make the unit tests pass before
this fix as it's not necessary any longer.

Closes #14918.

Note: See TracTickets for help on using tickets.