Scott
Scott

Reputation: 10697

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 setting for displaying numbers, time, money, etc and these could all vary. Any ideas about how to do this would be greatly appreciated!

Upvotes: 0

Views: 1142

Answers (2)

Steven R. Loomis
Steven R. Loomis

Reputation: 4350

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.

Upvotes: 2

Scott
Scott

Reputation: 10697

Seems this can be done with the locale.h functions

char * loc;
loc = setlocale(LC_TIME, "");

Upvotes: 1

Related Questions