1NL_LANGINFO(3P) POSIX Programmer's Manual NL_LANGINFO(3P)
2
3
4
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
11
13 nl_langinfo, nl_langinfo_l — language information
14
16 #include <langinfo.h>
17
18 char *nl_langinfo(nl_item item);
19 char *nl_langinfo_l(nl_item item, locale_t locale);
20
22 The nl_langinfo() and nl_langinfo_l() functions shall return a pointer
23 to a string containing information relevant to the particular language
24 or cultural area defined in the current locale, or in the locale repre‐
25 sented by locale, respectively (see <langinfo.h>). The manifest con‐
26 stant names and values of item are defined in <langinfo.h>. For exam‐
27 ple:
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 nl_langinfo_l(ABDAY_1, loc)
35
36 would return a pointer to the string "Dom" if the identified language
37 of the locale represented by loc was Portuguese, and "Sun" if the iden‐
38 tified language of the locale represented by loc was English.
39
40 The nl_langinfo() function need not be thread-safe.
41
42 The behavior is undefined if the locale argument to nl_langinfo_l() is
43 the special locale object LC_GLOBAL_LOCALE or is not a valid locale
44 object handle.
45
47 In a locale where langinfo data is not defined, these functions shall
48 return a pointer to the corresponding string in the POSIX locale. In
49 all locales, these functions shall return a pointer to an empty string
50 if item contains an invalid setting.
51
52 The application shall not modify the string returned. The pointer
53 returned by nl_langinfo() might be invalidated or the string content
54 might be overwritten by a subsequent call to nl_langinfo() in any
55 thread or to nl_langinfo_l() in the same thread or the initial thread,
56 by subsequent calls to setlocale() with a category corresponding to the
57 category of item (see <langinfo.h>) or the category LC_ALL, or by sub‐
58 sequent calls to uselocale() which change the category corresponding to
59 the category of item. The pointer returned by nl_langinfo_l() might be
60 invalidated or the string content might be overwritten by a subsequent
61 call to nl_langinfo_l() in the same thread or to nl_langinfo() in any
62 thread, or by subsequent calls to freelocale() or newlocale() which
63 free or modify the locale object that was passed to nl_langinfo_l().
64
66 No errors are defined.
67
68 The following sections are informative.
69
71 Getting Date and Time Formatting Information
72 The following example returns a pointer to a string containing date and
73 time formatting information, as defined in the LC_TIME category of the
74 current locale.
75
76 #include <time.h>
77 #include <langinfo.h>
78 ...
79 strftime(datestring, sizeof(datestring), nl_langinfo(D_T_FMT), tm);
80 ...
81
83 The array pointed to by the return value should not be modified by the
84 program, but may be modified by further calls to these functions.
85
87 The possible interactions between internal data used by nl_langinfo()
88 and nl_langinfo_l() are complicated by the fact that nl_langinfo_l()
89 must be thread-safe but nl_langinfo() need not be. The various imple‐
90 mentation choices are:
91
92 1. nl_langinfo_l() and nl_langinfo() use separate buffers, or at least
93 one of them does not use an internal string buffer. In this case
94 there are no interactions.
95
96 2. nl_langinfo_l() and nl_langinfo() share an internal per-thread buf‐
97 fer. There can be interactions, but only in the same thread.
98
99 3. nl_langinfo_l() uses an internal per-thread buffer, and nl_lang‐
100 info() uses (in all threads) the same buffer that nl_langinfo_l()
101 uses in the initial thread. There can be interactions, but only
102 when nl_langinfo_l() is called in the initial thread.
103
105 None.
106
108 setlocale(), uselocale()
109
110 The Base Definitions volume of POSIX.1‐2008, Chapter 7, Locale, <lang‐
111 info.h>, <locale.h>, <nl_types.h>
112
114 Portions of this text are reprinted and reproduced in electronic form
115 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
116 -- Portable Operating System Interface (POSIX), The Open Group Base
117 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
118 cal and Electronics Engineers, Inc and The Open Group. (This is
119 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
120 event of any discrepancy between this version and the original IEEE and
121 The Open Group Standard, the original IEEE and The Open Group Standard
122 is the referee document. The original Standard can be obtained online
123 at http://www.unix.org/online.html .
124
125 Any typographical or formatting errors that appear in this page are
126 most likely to have been introduced during the conversion of the source
127 files to man page format. To report such errors, see https://www.ker‐
128 nel.org/doc/man-pages/reporting_bugs.html .
129
130
131
132IEEE/The Open Group 2013 NL_LANGINFO(3P)