Ongy Ongy - 7 months ago 31
Linux Question

How to get extended locale information by api

I want to getinformation about the current locale.
The only interface I could find is:

locale.h: extern struct lconv *localeconv (void);

But the
struct lconv
only contains numeric and financial locale information. I also want to get the time related information that's used by strftime. In particular the names of days and date format.

locale abday
I found
but I cannot find any information about its format.

a3f a3f

Use nl_langinfo(3). From the glibc docs:

7.7 Accessing Locale Information

… To do this the C library provides two functions: localeconv and nl_langinfo. The former is part of ISO C and therefore portable, but has a brain-damaged interface. The second is part of the Unix interface and is portable in as far as the system follows the Unix standards.

The Lame Way to Locale Data: ISO C’s localeconv.

The Elegant and Fast Way: X/Open’s nl_langinfo.