cinternationalizationlocale

Is setlocale() in C restricted to locales shown by “locale -a”?


It seems like setlocale() in C (at least on Linux) only works if the locale you’re trying to set it to is one of those listed in the output of locale -a. Is this really true?

The reason I ask to confirm is that it seems like a potentially unpleasant restriction.


Solution

  • This is because locale -a merely lists the locales installed on the system. On Debian/Ubuntu based systems for example it looks for them under /usr/lib/locale. If a locale does not exist on the system, then you won't be able to use it, neither via setlocale() nor via any other means.