# nl_langinfo

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## NAME



           nl_langinfo, nl_langinfo_l — language information
    


## SYNOPSIS



           #include <langinfo.h>
    
           char *nl_langinfo(nl_item _item_);
           char *nl_langinfo_l(nl_item _item_ , locale_t _locale_);
    


## DESCRIPTION



           The _nl_langinfo_() and _nl_langinfo_l_() functions shall return a
           pointer to a string containing information relevant to the
           particular language or cultural area defined in the current
           locale, or in the locale represented by _locale_ , respectively (see
           _< langinfo.h>_).  The manifest constant names and values of _item_ are
           defined in _< langinfo.h>_.  For example:
    
               nl_langinfo(ABDAY_1)
    
           would return a pointer to the string **"Dom"** if the identified
           language was Portuguese, and **"Sun"** if the identified language was
           English.
    
               nl_langinfo_l(ABDAY_1, loc)
    
           would return a pointer to the string **"Dom"** if the identified
           language of the locale represented by _loc_ was Portuguese, and
           **"Sun"** if the identified language of the locale represented by _loc_
           was English.
    
           The _nl_langinfo_() function need not be thread-safe.
    
           The behavior is undefined if the _locale_ argument to
           _nl_langinfo_l_() is the special locale object LC_GLOBAL_LOCALE or
           is not a valid locale object handle.
    


## RETURN VALUE



           In a locale where _langinfo_ data is not defined, these functions
           shall return a pointer to the corresponding string in the POSIX
           locale. In all locales, these functions shall return a pointer to
           an empty string if _item_ contains an invalid setting.
    
           The application shall not modify the string returned. The pointer
           returned by _nl_langinfo_() might be invalidated or the string
           content might be overwritten by a subsequent call to _nl_langinfo_()
           in any thread or to _nl_langinfo_l_() in the same thread or the
           initial thread, by subsequent calls to _setlocale_() with a category
           corresponding to the category of _item_ (see _< langinfo.h>_) or the
           category LC_ALL, or by subsequent calls to _uselocale_() which
           change the category corresponding to the category of _item_.  The
           pointer returned by _nl_langinfo_l_() might be invalidated or the
           string content might be overwritten by a subsequent call to
           _nl_langinfo_l_() in the same thread or to _nl_langinfo_() in any
           thread, or by subsequent calls to _freelocale_() or _newlocale_()
           which free or modify the locale object that was passed to
           _nl_langinfo_l_().  The returned pointer and the string content
           might also be invalidated if the calling thread is terminated.
    


## ERRORS



           No errors are defined.
    
           _The following sections are informative._
    


## EXAMPLES



       **Getting Date and Time Formatting Information**
           The following example returns a pointer to a string containing
           date and time formatting information, as defined in the _LC_TIME_
           category of the current locale.
    
               #include <time.h>
               #include <langinfo.h>
               ...
               strftime(datestring, sizeof(datestring), nl_langinfo(D_T_FMT), tm);
               ...
    


## APPLICATION USAGE



           The array pointed to by the return value should not be modified by
           the program, but may be modified by further calls to these
           functions.
    


## RATIONALE



           The possible interactions between internal data used by
           _nl_langinfo_() and _nl_langinfo_l_() are complicated by the fact that
           _nl_langinfo_l_() must be thread-safe but _nl_langinfo_() need not be.
           The various implementation choices are:
    
            1. _nl_langinfo_l_() and _nl_langinfo_() use separate buffers, or at
               least one of them does not use an internal string buffer. In
               this case there are no interactions.
    
            2. _nl_langinfo_l_() and _nl_langinfo_() share an internal per-thread
               buffer. There can be interactions, but only in the same
               thread.
    
            3. _nl_langinfo_l_() uses an internal per-thread buffer, and
               _nl_langinfo_() uses (in all threads) the same buffer that
               _nl_langinfo_l_() uses in the initial thread. There can be
               interactions, but only when _nl_langinfo_l_() is called in the
               initial thread.
    


## FUTURE DIRECTIONS



           None.
    


* * *