|
From: Pedro A. <pa...@dc...> - 2007-09-13 01:43:49
|
On Thu, 13 Sep 2007 00:34:14 +0100 "Diogo Teixeira" <fo...@gm...> wrote: > Roger that. >=20 > I'm doing the locale functions at the moment. We might have to do > an OS dependent implementation. I can't find ANSI functions to > retrieve the language and country codes in the formats specified by > the spec: ISO 639-1 and ISO 3166-1 alpha-2 respectively. Any ideas? I think what you are looking for is the aptly named setlocale() function from the standard <locale.h> header: http://www.cplusplus.com/reference/clibrary/clocale/ On my machine, setlocale (LC_CTYPE, NULL) returns the string "en_US.UTF-8" which is the ISO 639-1 language code followed by a "_" followed by the ISO 3166-1 alpha 2 country code followed by a "." and the default character encoding for the locale. Here's the sample code I used for testing: #include <locale.h> #include <stdio.h> int main (int argc, char **argv) { /* * Set the program environment locale to the "native" locale.=20 * You need to do this if you care about the platform's locale=20 * because by default the program environment locale is set to * "C". */ setlocale (LC_ALL, ""); setlocale (LC_CTYPE, ""); /* Get the locale strings */ char *locale_all =3D setlocale (LC_ALL, NULL); char *locale_ctype =3D setlocale (LC_CTYPE, NULL); printf ("LC_ALL=3D%s\nLC_CTYPE=3D%s\n", locale_all, locale_ctype); return(0); } > We might have to provide initialization and finalization functions > for the subsystems. Since we have control over the main entry point, > my suggestion is the following: >=20 > int main(int argc, char* argv[]) > { > init_events(); > init_locale(); >=20 > kdMain(argc, argv); >=20 > free_locale(); > free_events(); > } This seems sensible. I suggest we unify the namespaces for internal access to freekode subsystems, something like: fk_events_init(); fk_events_close(); fk_locale_init(); fk_locale_close(); ... fk_<subsystem>_<function>(); Cheers P. |