1nl_langinfo(3)             Library Functions Manual             nl_langinfo(3)
2
3
4

NAME

6       nl_langinfo, nl_langinfo_l - query language and locale information
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <langinfo.h>
13
14       char *nl_langinfo(nl_item item);
15       char *nl_langinfo_l(nl_item item, locale_t locale);
16
17   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19       nl_langinfo_l():
20           Since glibc 2.24:
21               _POSIX_C_SOURCE >= 200809L
22           glibc 2.23 and earlier:
23               _POSIX_C_SOURCE >= 200112L
24

DESCRIPTION

26       The  nl_langinfo()  and nl_langinfo_l() functions provide access to lo‐
27       cale information in a more flexible way than  localeconv(3).   nl_lang‐
28       info() returns a string which is the value corresponding to item in the
29       program's current global  locale.   nl_langinfo_l()  returns  a  string
30       which  is  the value corresponding to item for the locale identified by
31       the locale object locale, which was previously created by newlocale(3).
32       Individual  and  additional  elements  of  the locale categories can be
33       queried.
34
35       Examples for the locale elements that can be specified  in  item  using
36       the constants defined in <langinfo.h> are:
37
38       CODESET (LC_CTYPE)
39              Return  a string with the name of the character encoding used in
40              the  selected  locale,  such  as   "UTF-8",   "ISO-8859-1",   or
41              "ANSI_X3.4-1968"  (better  known as US-ASCII).  This is the same
42              string that you get with "locale charmap".  For a list of  char‐
43              acter encoding names, try "locale -m" (see locale(1)).
44
45       D_T_FMT (LC_TIME)
46              Return  a  string  that can be used as a format string for strf‐
47              time(3) to represent time and date in a locale-specific way  (%c
48              conversion specification).
49
50       D_FMT (LC_TIME)
51              Return  a  string  that can be used as a format string for strf‐
52              time(3) to represent a date in a locale-specific way (%x conver‐
53              sion specification).
54
55       T_FMT (LC_TIME)
56              Return  a  string  that can be used as a format string for strf‐
57              time(3) to represent a time in a locale-specific way (%X conver‐
58              sion specification).
59
60       AM_STR (LC_TIME)
61              Return  a string that represents affix for ante meridiem (before
62              noon, "AM") time.  (Used in %p strftime(3) conversion specifica‐
63              tion.)
64
65       PM_STR (LC_TIME)
66              Return  a string that represents affix for post meridiem (before
67              midnight, "PM") time.  (Used in %p strftime(3) conversion speci‐
68              fication.)
69
70       T_FMT_AMPM (LC_TIME)
71              Return  a  string  that can be used as a format string for strf‐
72              time(3) to represent a time in a.m. or p.m. notation  in  a  lo‐
73              cale-specific way (%r conversion specification).
74
75       ERA (LC_TIME)
76              Return  era  description,  which  contains information about how
77              years are counted and displayed for each era in a locale.   Each
78              era description segment shall have the format:
79
80                     direction:offset:start_date:end_date:era_name:era_format
81
82              according to the definitions below:
83
84              direction   Either a "+" or a "-" character.  The "+" means that
85                          years  increase  from  the  start_date  towards  the
86                          end_date, "-" means the opposite.
87
88              offset      The epoch year of the start_date.
89
90              start_date  A  date  in the form yyyy/mm/dd, where yyyy, mm, and
91                          dd are the year, month, and day numbers respectively
92                          of the start of the era.
93
94              end_date    The  ending  date  of the era, in the same format as
95                          the start_date, or one of  the  two  special  values
96                          "-*" (minus infinity) or "+*" (plus infinity).
97
98              era_name    The  name of the era, corresponding to the %EC strf‐
99                          time(3) conversion specification.
100
101              era_format  The format of the year in the era, corresponding  to
102                          the %EY strftime(3) conversion specification.
103
104              Era  description segments are separated by semicolons.  Most lo‐
105              cales do not define this value.  Examples of locales that do de‐
106              fine this value are the Japanese and Thai locales.
107
108       ERA_D_T_FMT (LC_TIME)
109              Return  a  string  that can be used as a format string for strf‐
110              time(3) for alternative representation of time and date in a lo‐
111              cale-specific way (%Ec conversion specification).
112
113       ERA_D_FMT (LC_TIME)
114              Return  a  string  that can be used as a format string for strf‐
115              time(3) for alternative representation of a date  in  a  locale-
116              specific way (%Ex conversion specification).
117
118       ERA_T_FMT (LC_TIME)
119              Return  a  string  that can be used as a format string for strf‐
120              time(3) for alternative representation of a time  in  a  locale-
121              specific way (%EX conversion specification).
122
123       DAY_{1–7} (LC_TIME)
124              Return name of the n-th day of the week.  [Warning: this follows
125              the US convention DAY_1 = Sunday, not the international  conven‐
126              tion  (ISO  8601)  that  Monday  is  the first day of the week.]
127              (Used in %A strftime(3) conversion specification.)
128
129       ABDAY_{1–7} (LC_TIME)
130              Return abbreviated name of the n-th day of the week.   (Used  in
131              %a strftime(3) conversion specification.)
132
133       MON_{1–12} (LC_TIME)
134              Return  name of the n-th month.  (Used in %B strftime(3) conver‐
135              sion specification.)
136
137       ABMON_{1–12} (LC_TIME)
138              Return abbreviated name of the n-th month.  (Used  in  %b  strf‐
139              time(3) conversion specification.)
140
141       RADIXCHAR (LC_NUMERIC)
142              Return radix character (decimal dot, decimal comma, etc.).
143
144       THOUSEP (LC_NUMERIC)
145              Return  separator  character for thousands (groups of three dig‐
146              its).
147
148       YESEXPR (LC_MESSAGES)
149              Return a regular expression that can be used with  the  regex(3)
150              function to recognize a positive response to a yes/no question.
151
152       NOEXPR (LC_MESSAGES)
153              Return  a  regular expression that can be used with the regex(3)
154              function to recognize a negative response to a yes/no question.
155
156       CRNCYSTR (LC_MONETARY)
157              Return the currency symbol, preceded by "-" if the symbol should
158              appear  before  the value, "+" if the symbol should appear after
159              the value, or "." if the symbol should replace the radix charac‐
160              ter.
161
162       The  above  list  covers  just  some  examples of items that can be re‐
163       quested.  For a more detailed list, consult The GNU C Library Reference
164       Manual.
165

RETURN VALUE

167       On  success,  these functions return a pointer to a string which is the
168       value corresponding to item in the specified locale.
169
170       If no locale has been selected by setlocale(3) for the appropriate cat‐
171       egory,  nl_langinfo()  return  a pointer to the corresponding string in
172       the "C" locale.  The same is true of nl_langinfo_l() if  locale  speci‐
173       fies a locale where langinfo data is not defined.
174
175       If item is not valid, a pointer to an empty string is returned.
176
177       The  pointer  returned by these functions may point to static data that
178       may be overwritten, or the pointer itself may be invalidated, by a sub‐
179       sequent  call  to nl_langinfo(), nl_langinfo_l(), or setlocale(3).  The
180       same statements apply to nl_langinfo_l() if the locale object  referred
181       to by locale is freed or modified by freelocale(3) or newlocale(3).
182
183       POSIX specifies that the application may not modify the string returned
184       by these functions.
185

ATTRIBUTES

187       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
188       tributes(7).
189
190       ┌─────────────────────────────────────┬───────────────┬────────────────┐
191Interface                            Attribute     Value          
192       ├─────────────────────────────────────┼───────────────┼────────────────┤
193nl_langinfo()                        │ Thread safety │ MT-Safe locale │
194       └─────────────────────────────────────┴───────────────┴────────────────┘
195

STANDARDS

197       POSIX.1-2008.
198

HISTORY

200       POSIX.1-2001, SUSv2.
201

NOTES

203       The  behavior  of nl_langinfo_l() is undefined if locale is the special
204       locale object LC_GLOBAL_LOCALE or is not a valid locale object handle.
205

EXAMPLES

207       The following program sets the character type and  the  numeric  locale
208       according to the environment and queries the terminal character set and
209       the radix character.
210
211       #include <langinfo.h>
212       #include <locale.h>
213       #include <stdio.h>
214       #include <stdlib.h>
215
216       int
217       main(void)
218       {
219           setlocale(LC_CTYPE, "");
220           setlocale(LC_NUMERIC, "");
221
222           printf("%s\n", nl_langinfo(CODESET));
223           printf("%s\n", nl_langinfo(RADIXCHAR));
224
225           exit(EXIT_SUCCESS);
226       }
227

SEE ALSO

229       locale(1), localeconv(3), setlocale(3), charsets(7), locale(7)
230
231       The GNU C Library Reference Manual
232
233
234
235Linux man-pages 6.04              2023-03-30                    nl_langinfo(3)
Impressum