|
From: Pedro A. <pa...@dc...> - 2007-09-13 11:59:38
|
On Thu, 13 Sep 2007 09:39:18 +0100 "Diogo Teixeira" <fo...@gm...> wrote: > I guess I should have been more specific. > > Obviously, the first functions I tested were the ones provided by C > locale. The problem is... you can set those strings to whatever you > want using setlocale() > because no convention is mentioned except that the format _should_ be > something > like: language[_territory][.codeset] > > For example, your code on my platform results in: > LC_ALL=Portuguese_Portugal.1252 > LC_CTYPE=Portuguese_Portugal.1252 > > Which does not comply with the ISO defined by the spec. I guess it > makes sense to > use such a convention, for the sake of kdGetLocale() being anywhere > near useful. I can now feel your pain. After a bit of search on MSDN I found out that setlocale() returns "human readable" strings for the locale and if you want to get ISO codes you have to use GetSystemDefaultLocaleName(), GetUSerDefaultLocaleName() or GetThreadLocale() from <winnls.h> (included by <windows.h>). In this case, other than building a translation table for different meanings of the setlocale() return value for each platform, we're probably better off providing platform-specific implementations. P. |