NL_LANGINFO(3)             POSIX Programmer's Manual            NL_LANGINFO(3)



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

NNAAMMEE
       nl_langinfo, nl_langinfo_l -- language information

SSYYNNOOPPSSIISS
       #include <langinfo.h>

       char *nl_langinfo(nl_item _i_t_e_m);
       char *nl_langinfo_l(nl_item _i_t_e_m, locale_t _l_o_c_a_l_e);

DDEESSCCRRIIPPTTIIOONN
       The _n_l___l_a_n_g_i_n_f_o() and _n_l___l_a_n_g_i_n_f_o___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 _l_o_c_a_l_e, respectively (see _<_l_a_n_g_i_n_f_o_._h_>).  The manifest
       constant names and values of _i_t_e_m are defined in _<_l_a_n_g_i_n_f_o_._h_>.  For
       example:


           nl_langinfo(ABDAY_1)

       would return a pointer to the string ""DDoomm"" if the identified language
       was Portuguese, and ""SSuunn"" if the identified language was English.


           nl_langinfo_l(ABDAY_1, loc)

       would return a pointer to the string ""DDoomm"" if the identified language
       of the locale represented by _l_o_c was Portuguese, and ""SSuunn"" if the
       identified language of the locale represented by _l_o_c was English.

       The _n_l___l_a_n_g_i_n_f_o() function need not be thread-safe.

       The behavior is undefined if the _l_o_c_a_l_e argument to _n_l___l_a_n_g_i_n_f_o___l() is
       the special locale object LC_GLOBAL_LOCALE or is not a valid locale
       object handle.

RREETTUURRNN VVAALLUUEE
       In a locale where _l_a_n_g_i_n_f_o 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 _i_t_e_m contains an invalid setting.

       The application shall not modify the string returned. The pointer
       returned by _n_l___l_a_n_g_i_n_f_o() might be invalidated or the string content
       might be overwritten by a subsequent call to _n_l___l_a_n_g_i_n_f_o() in any
       thread or to _n_l___l_a_n_g_i_n_f_o___l() in the same thread or the initial thread,
       by subsequent calls to _s_e_t_l_o_c_a_l_e() with a category corresponding to the
       category of _i_t_e_m (see _<_l_a_n_g_i_n_f_o_._h_>) or the category LC_ALL, or by
       subsequent calls to _u_s_e_l_o_c_a_l_e() which change the category corresponding
       to the category of _i_t_e_m.  The pointer returned by _n_l___l_a_n_g_i_n_f_o___l() might
       be invalidated or the string content might be overwritten by a
       subsequent call to _n_l___l_a_n_g_i_n_f_o___l() in the same thread or to
       _n_l___l_a_n_g_i_n_f_o() in any thread, or by subsequent calls to _f_r_e_e_l_o_c_a_l_e() or
       _n_e_w_l_o_c_a_l_e() which free or modify the locale object that was passed to
       _n_l___l_a_n_g_i_n_f_o___l().  The returned pointer and the string content might
       also be invalidated if the calling thread is terminated.

EERRRROORRSS
       No errors are defined.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
   GGeettttiinngg DDaattee aanndd TTiimmee FFoorrmmaattttiinngg IInnffoorrmmaattiioonn
       The following example returns a pointer to a string containing date and
       time formatting information, as defined in the _L_C___T_I_M_E category of the
       current locale.


           #include <time.h>
           #include <langinfo.h>
           ...
           strftime(datestring, sizeof(datestring), nl_langinfo(D_T_FMT), tm);
           ...

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       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.

RRAATTIIOONNAALLEE
       The possible interactions between internal data used by _n_l___l_a_n_g_i_n_f_o()
       and _n_l___l_a_n_g_i_n_f_o___l() are complicated by the fact that _n_l___l_a_n_g_i_n_f_o___l()
       must be thread-safe but _n_l___l_a_n_g_i_n_f_o() need not be. The various
       implementation choices are:

        1. _n_l___l_a_n_g_i_n_f_o___l() and _n_l___l_a_n_g_i_n_f_o() use separate buffers, or at least
           one of them does not use an internal string buffer. In this case
           there are no interactions.

        2. _n_l___l_a_n_g_i_n_f_o___l() and _n_l___l_a_n_g_i_n_f_o() share an internal per-thread
           buffer. There can be interactions, but only in the same thread.

        3. _n_l___l_a_n_g_i_n_f_o___l() uses an internal per-thread buffer, and
           _n_l___l_a_n_g_i_n_f_o() uses (in all threads) the same buffer that
           _n_l___l_a_n_g_i_n_f_o___l() uses in the initial thread. There can be
           interactions, but only when _n_l___l_a_n_g_i_n_f_o___l() is called in the
           initial thread.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _s_e_t_l_o_c_a_l_e(), _u_s_e_l_o_c_a_l_e()

       The Base Definitions volume of POSIX.1-2017, _C_h_a_p_t_e_r _7, _L_o_c_a_l_e,
       <<llaannggiinnffoo..hh>>, <<llooccaallee..hh>>, <<nnll__ttyyppeess..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  In the event of any discrepancy between this version and the
       original IEEE and The Open Group Standard, the original IEEE and The
       Open Group Standard is the referee document. The original Standard can
       be obtained online at http://www.opengroup.org/unix/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                       NL_LANGINFO(3)
