nl_langinfo() — Retrieve locale information

Standards

Standards / Extensions C or C++ Dependencies

XPG4
XPG4.2
Single UNIX Specification, Version 3

both  

Format

#include <langinfo.h>

char *nl_langinfo(nl_item item);

General description

Retrieves from the current locale the string that describes the requested information specified by item.

For a list of macros that define the constants used to identify the information queried in the current locale, see Table 1.

Returned value

If successful, nl_langinfo() returns a pointer to a NULL-terminated string containing information concerning the active language or cultural area. The active language or cultural area is determined by the most recent setlocale() call. The array pointed to by the returned value is modified by subsequent calls to the function. The array shall not be modified by the user's program.

If the item is not valid, nl_langinfo() returns a pointer to an empty string.

Example

CELEBN01
⁄* CELEBN01                                      

   This example retrieves the current codeset name using the                    
   &nll. function.                                                              
                                                                                
 *⁄                                                                             
#include "langinfo.h"                                                           
#include "locale.h"                                                             
#include "stdio.h"                                                              
                                                                                
main() {                                                                        
   char *codeset;                                                               
   setlocale(LC_ALL, "");                                                       
   codeset = nl_langinfo(CODESET);                                              
   printf("codeset is %s\n", codeset);                                          
}                                                                               

Related information