Getting the current locale with ICU
Many ICU functions take a char * representing the locale as a parameter. If I statically set this to "ko_KR", for example, then it does indeed operate in a locale-sensitive manner.
However, I want to determine the current locale based on system settings for time formatting. As far as I understand, most systems have a locale set开发者_Python百科ting for displaying numbers, time, money, etc and these could all vary. Any ideas about how to do this would be greatly appreciated!
uloc_getDefault() will return the overall default locale that ICU detected from the underlying system. The categories you mentioned don't cleanly map across all operating systems.
Seems this can be done with the locale.h functions
char * loc;
loc = setlocale(LC_TIME, "");
精彩评论