nl_langinfo
query language and locale information
- Provided by: manpages-dev (Version: 3.54-1ubuntu1)
- Source: manpages
- Report a bug
query language and locale information
#include <langinfo.h> char *nl_langinfo(nl_item item);
The nl_langinfo() function provides access to locale information in a more flexible way than localeconv(3) does. Individual and additional elements of the locale categories can be queried. setlocale(3) needs to be executed with proper arguments before.
Examples for the locale elements that can be specified in item using the constants defined in <langinfo.h> are:
The above list covers just some examples of items that can be requested. For a more detailed list, consult The GNU C Library Reference Manual.
If no locale has been selected by setlocale(3) for the appropriate category, nl_langinfo() returns a pointer to the corresponding string in the "C" locale.
If item is not valid, a pointer to an empty string is returned.
This pointer may point to static data that may be overwritten on the next call to nl_langinfo() or setlocale(3).
SUSv2, POSIX.1-2001.
The following program sets the character type locale according to the environment and queries the terminal character set.
#include <langinfo.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
setlocale(LC_CTYPE,"");
printf("%s\n",nl_langinfo(CODESET));
exit(EXIT_SUCCESS);
}
locale(1), localeconv(3), setlocale(3),
charsets(7), locale(7)
The GNU C Library Reference Manual
This page is part of release 3.54 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.