1NL_LANGINFO(3P)            POSIX Programmer's Manual           NL_LANGINFO(3P)
2
3
4

PROLOG

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

NAME

12       nl_langinfo, nl_langinfo_l — language information
13

SYNOPSIS

15       #include <langinfo.h>
16
17       char *nl_langinfo(nl_item item);
18       char *nl_langinfo_l(nl_item item, locale_t locale);
19

DESCRIPTION

21       The nl_langinfo() and nl_langinfo_l() functions shall return a  pointer
22       to  a string containing information relevant to the particular language
23       or cultural area defined in the current locale, or in the locale repre‐
24       sented  by  locale, respectively (see <langinfo.h>).  The manifest con‐
25       stant names and values of item are defined in <langinfo.h>.  For  exam‐
26       ple:
27
28
29           nl_langinfo(ABDAY_1)
30
31       would  return  a pointer to the string "Dom" if the identified language
32       was Portuguese, and "Sun" if the identified language was English.
33
34
35           nl_langinfo_l(ABDAY_1, loc)
36
37       would return a pointer to the string "Dom" if the  identified  language
38       of the locale represented by loc was Portuguese, and "Sun" if the iden‐
39       tified language of the locale represented by loc was English.
40
41       The nl_langinfo() function need not be thread-safe.
42
43       The behavior is undefined if the locale argument to nl_langinfo_l()  is
44       the  special  locale  object  LC_GLOBAL_LOCALE or is not a valid locale
45       object handle.
46

RETURN VALUE

48       In a locale where langinfo data is not defined, these  functions  shall
49       return  a  pointer  to the corresponding string in the POSIX locale. In
50       all locales, these functions shall return a pointer to an empty  string
51       if item contains an invalid setting.
52
53       The  application  shall  not  modify  the  string returned. The pointer
54       returned by nl_langinfo() might be invalidated or  the  string  content
55       might  be  overwritten  by  a  subsequent  call to nl_langinfo() in any
56       thread or to nl_langinfo_l() in the same thread or the initial  thread,
57       by subsequent calls to setlocale() with a category corresponding to the
58       category of item (see <langinfo.h>) or the category LC_ALL, or by  sub‐
59       sequent calls to uselocale() which change the category corresponding to
60       the category of item.  The pointer returned by nl_langinfo_l() might be
61       invalidated  or the string content might be overwritten by a subsequent
62       call to nl_langinfo_l() in the same thread or to nl_langinfo()  in  any
63       thread,  or  by  subsequent  calls to freelocale() or newlocale() which
64       free or modify the locale object that was  passed  to  nl_langinfo_l().
65       The  returned  pointer and the string content might also be invalidated
66       if the calling thread is terminated.
67

ERRORS

69       No errors are defined.
70
71       The following sections are informative.
72

EXAMPLES

74   Getting Date and Time Formatting Information
75       The following example returns a pointer to a string containing date and
76       time  formatting information, as defined in the LC_TIME category of the
77       current locale.
78
79
80           #include <time.h>
81           #include <langinfo.h>
82           ...
83           strftime(datestring, sizeof(datestring), nl_langinfo(D_T_FMT), tm);
84           ...
85

APPLICATION USAGE

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

RATIONALE

91       The  possible  interactions between internal data used by nl_langinfo()
92       and nl_langinfo_l() are complicated by the  fact  that  nl_langinfo_l()
93       must  be  thread-safe but nl_langinfo() need not be. The various imple‐
94       mentation choices are:
95
96        1. nl_langinfo_l() and nl_langinfo() use separate buffers, or at least
97           one  of  them  does not use an internal string buffer. In this case
98           there are no interactions.
99
100        2. nl_langinfo_l() and nl_langinfo() share an internal per-thread buf‐
101           fer. There can be interactions, but only in the same thread.
102
103        3. nl_langinfo_l()  uses  an  internal per-thread buffer, and nl_lang‐
104           info() uses (in all threads) the same buffer  that  nl_langinfo_l()
105           uses  in  the  initial  thread. There can be interactions, but only
106           when nl_langinfo_l() is called in the initial thread.
107

FUTURE DIRECTIONS

109       None.
110

SEE ALSO

112       setlocale(), uselocale()
113
114       The Base Definitions volume of POSIX.1‐2017, Chapter 7, Locale,  <lang‐
115       info.h>, <locale.h>, <nl_types.h>
116
118       Portions  of  this text are reprinted and reproduced in electronic form
119       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
120       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
121       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
122       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
123       event of any discrepancy between this version and the original IEEE and
124       The  Open Group Standard, the original IEEE and The Open Group Standard
125       is the referee document. The original Standard can be  obtained  online
126       at http://www.opengroup.org/unix/online.html .
127
128       Any  typographical  or  formatting  errors that appear in this page are
129       most likely to have been introduced during the conversion of the source
130       files  to  man page format. To report such errors, see https://www.ker
131       nel.org/doc/man-pages/reporting_bugs.html .
132
133
134
135IEEE/The Open Group                  2017                      NL_LANGINFO(3P)
Impressum