Internationalization/posix locale
Contents
Summary
My Summary is based on article by Michael Becker (see here).This summary is more or less concerning SuSE-Linux.
There are differences between User-locale and C-locale. C-locale, is the local, which is only effectual in C-environment. Outside C-environment if there is no other locale set, the C-locale is then effectual, which is called "POSIX"-locale.
With C-command setlocale (LC_ALL,"")
one set C-locale with User-locale. So one could retrieve details about User-locale information with C-functions.
Listing available locales
There are two directories that one could get information about locales. They are: /usr/share/locale/ /usr/share/i18n/
In the first directory, the locales are binary files. So we could not need them for our purpose since i do not know how to read them for the moment.
In the second directory there are at least 2 subdirectories, with names charmaps and locales.
Shell command ls /usr/share/i18n/locales/ list all the available locales.
Checking for default locale
With shell command "locale" one can get infomation about default locale. In C, to get details of localeone can use
setlocale (LC_ALL,"") localeconv()
see manpage locale(7) to get more information.
Retrieving locale information
C-command nl_langinfo()
(defined in langinfo.h) one could get information about all categories.
For example, with nl_langinfo(D_T_FMT)
, one get a pointer at a string, which in form of %a %d %b %Y %T %Z.
Other information
Using a parser one could also retrieve locale information, about which I do not have a lot of idea.
Still there are C-functions to use categories. For example,
strftime() strptime() wcsftime()
for LC_TIME For another example,
isalnum isalpha isblank
and so on for LC_CTYPE.
For more information please read local-Specification of Unix Open