1NL_LANGINFO(3)             Linux Programmer's Manual            NL_LANGINFO(3)
2
3
4

NAME

6       nl_langinfo, nl_langinfo_l - query language and locale information
7

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ATTRIBUTES

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

CONFORMING TO

194       POSIX.1-2001, POSIX.1-2008, SUSv2.
195

NOTES

197       The  behavior  of nl_langinfo_l() is undefined if locale is the special
198       locale object LC_GLOBAL_LOCALE or is not a valid locale object handle.
199

EXAMPLES

201       The following program sets the character type and  the  numeric  locale
202       according to the environment and queries the terminal character set and
203       the radix character.
204
205       #include <langinfo.h>
206       #include <locale.h>
207       #include <stdio.h>
208       #include <stdlib.h>
209
210       int
211       main(int argc, char *argv[])
212       {
213           setlocale(LC_CTYPE, "");
214           setlocale(LC_NUMERIC, "");
215
216           printf("%s\n", nl_langinfo(CODESET));
217           printf("%s\n", nl_langinfo(RADIXCHAR));
218
219           exit(EXIT_SUCCESS);
220       }
221

SEE ALSO

223       locale(1), localeconv(3), setlocale(3), charsets(7), locale(7)
224
225       The GNU C Library Reference Manual
226

COLOPHON

228       This page is part of release 5.13 of the Linux  man-pages  project.   A
229       description  of  the project, information about reporting bugs, and the
230       latest    version    of    this    page,    can     be     found     at
231       https://www.kernel.org/doc/man-pages/.
232
233
234
235GNU                               2021-03-22                    NL_LANGINFO(3)
Impressum