wxLOCALE_DECIMAL_POINT always comma on wx2.9
Riccardo Cohen
rcohen at articque.com
Mon Jan 28 06:18:51 PST 2008
thanks a lot, i did not look at dev list archives... I found an
interesting thread the 9th jan, but no direct answer. The thing I don't
understand is that even if the function gives locale information for the
current user instead of the one set in the program, why does it provide
a comma while my MacOsX and my Vista are both in english... Well maybe
it uses the country instead of the language ? Something like that
my version : 2.9.0.0 as said in version.h, and the
intl.cpp header is
// RCS-ID: $Id: init.cpp 50455 2007-12-03 10:21:44Z RR $
For windows :
The function called is ::GetLocaleInfo(), and in the code, the locale id
provided to the function is LOCALE_USER_DEFAULT, while a new locale id
should be given thanks to DWORD MAKELCID(WORD wLanguageID, WORD
wSortID); as written in the MS doc.
For macos :
the function called is CFLocaleGetValue() and the locale id is
CFLocaleCopyCurrent(), while it seems to be quite easy to use
application defined locale :
CFStringRef localeIdent = CFSTR("fr_FR");
CFLocaleRef localeRef = CFLocaleCreate(kCFAllocatorDefault, localeIdent);
In the mean time I'll call the native function in my code.
Thanks
Vadim Zeitlin wrote:
> On Sun, 27 Jan 2008 22:44:45 +0100 Riccardo Cohen <rcohen at articque.com> wrote:
>
> RC> This code seems to answer the wrong result :
> RC>
> RC> wxLocale loc;
> RC> //int langid=wxLANGUAGE_FRENCH;
> RC> //int langid=wxLANGUAGE_ENGLISH_US;
> RC> int langid=wxLANGUAGE_ENGLISH_UK;
> RC> loc.Init(langid,0);
> RC> const wxLanguageInfo *info=wxLocale::GetLanguageInfo(langid);
> RC> wxString lang=info->CanonicalName;
> RC> wxString
> RC> dec=wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT,wxLOCALE_CAT_NUMBER);
> RC> out->SetValue(wxString::Format(wxT("in %s dec=%s"),lang,dec));
> RC>
> RC> I get a comma, while I should have a point.
> RC> I tried on windows and mac, it is the same.
> RC> I tried with the 3 locale (fr,uk,us), it is always a comma.
>
> Under Windows wxLocale::GetInfo() used to use the default user locale
> (i.e. the Windows language) and not the current "C" locale. This has been
> recently changed so it would be useful to know which revision of wx exactly
> do you use and if it's not the latest one, whether you still have the bug
> with it.
>
> Under Unix it definitely works correctly but Mac uses its own version of
> this code which retrieves information from CFLocaleCopyCurrent() which
> seems as wrong as the old MSW code, i.e. it uses the default user locale
> instead of the current one so it could explain that it doesn't work if you
> use a non-default one.
>
> RC> Actually I do that because I need to store double in a text
> RC> representation portable on many languages. And at read time, I need to
> RC> know what is the current decimal point before calling wxString::ToDouble() !
>
> This is a common problem and has been discussed many times in the past,
> just search for ToDouble() in this list and/or wx-dev archives. The
> simplest way to avoid it is to use std::stringstream instead of this
> function.
>
> Regards,
> VZ
>
--
Très cordialement,
Riccardo Cohen
-------------------------------------------
Articque
http://www.articque.com
149 av Général de Gaulle
37230 Fondettes - France
tel : 02-47-49-90-49
fax : 02-47-49-91-49
More information about the wx-users
mailing list