Reputation: 6847
char *currentLocale = setlocale(LC_ALL,"");
In windows setlocale returns "English_United States", but in linux it retruns "en_US". Is there a universal method to recognize english locale? Or I have to go over all available locales values? ("English_United States" || "en_US" || etc)
Upvotes: 2
Views: 205
Reputation: 4143
You may want to check:
http://en.wikipedia.org/wiki/Locale
http://en.wikipedia.org/wiki/ISO_639
In theory, Windows, Linux, MAc, and other O.S. may have function libraries that support the "language underscore country" format, even if they have their internal standard:
http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
Upvotes: 1
Reputation: 19615
It seems Windows is the only outlier in this case - most operating systems use the (saner) "en_US" format. You could use something like #ifdef to supply custom code to Windows compilers:
#ifdef __unix__
setlocale(LC_ALL, "en_US");
#elif defined _WIN32
setlocale(LC_ALL, "English");
#else
#error "Can't figure out how to set locale to English. Stop.";
#endif
It isn't very pretty, but it should work.
Upvotes: 0