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
13       char *nl_langinfo_l(nl_item item, locale_t locale);
14
15   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17       nl_langinfo_l():
18           Since glibc 2.24:
19               _POSIX_C_SOURCE >= 200809L
20           Glibc 2.23 and earlier:
21               _POSIX_C_SOURCE >= 200112L
22

DESCRIPTION

24       The  nl_langinfo()  and  nl_langinfo_l()  functions  provide  access to
25       locale information in a more flexible way than localeconv(3).  nl_lang‐
26       info() returns a string which is the value corresponding to item in the
27       program's current global locale.  nl_langinfo() returns a string  which
28       is  the  value  corresponding  to item for the locale identified by the
29       locale object locale, which was  previously  created  by  newlocale(1).
30       Individual  and  additional  elements  of  the locale categories can be
31       queried.
32
33       Examples for the locale elements that can be specified  in  item  using
34       the constants defined in <langinfo.h> are:
35
36       CODESET (LC_CTYPE)
37              Return  a string with the name of the character encoding used in
38              the  selected  locale,  such  as   "UTF-8",   "ISO-8859-1",   or
39              "ANSI_X3.4-1968"  (better  known as US-ASCII).  This is the same
40              string that you get with "locale charmap".  For a list of  char‐
41              acter encoding names, try "locale -m" (see locale(1)).
42
43       D_T_FMT (LC_TIME)
44              Return  a  string  that can be used as a format string for strf‐
45              time(3) to represent time and date in a locale-specific way.
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.
50
51       T_FMT (LC_TIME)
52              Return  a  string  that can be used as a format string for strf‐
53              time(3) to represent a time in a locale-specific way.
54
55       DAY_{1–7} (LC_TIME)
56              Return name of the n-th day of the week. [Warning: this  follows
57              the  US convention DAY_1 = Sunday, not the international conven‐
58              tion (ISO 8601) that Monday is the first day of the week.]
59
60       ABDAY_{1–7} (LC_TIME)
61              Return abbreviated name of the n-th day of the week.
62
63       MON_{1–12} (LC_TIME)
64              Return name of the n-th month.
65
66       ABMON_{1–12} (LC_TIME)
67              Return abbreviated name of the n-th month.
68
69       RADIXCHAR (LC_NUMERIC)
70              Return radix character (decimal dot, decimal comma, etc.).
71
72       THOUSEP (LC_NUMERIC)
73              Return separator character for thousands (groups of  three  dig‐
74              its).
75
76       YESEXPR (LC_MESSAGES)
77              Return  a  regular expression that can be used with the regex(3)
78              function to recognize a positive response to a yes/no question.
79
80       NOEXPR (LC_MESSAGES)
81              Return a regular expression that can be used with  the  regex(3)
82              function to recognize a negative response to a yes/no question.
83
84       CRNCYSTR (LC_MONETARY)
85              Return the currency symbol, preceded by "-" if the symbol should
86              appear before the value, "+" if the symbol should  appear  after
87              the value, or "." if the symbol should replace the radix charac‐
88              ter.
89
90       The above  list  covers  just  some  examples  of  items  that  can  be
91       requested.   For a more detailed list, consult The GNU C Library Refer‐
92       ence Manual.
93

RETURN VALUE

95       On success, these functions return a pointer to a string which  is  the
96       value corresponding to item in the specified locale.
97
98       If no locale has been selected by setlocale(3) for the appropriate cat‐
99       egory, nl_langinfo() return a pointer to the  corresponding  string  in
100       the  "C"  locale.  The same is true of nl_langinfo_l() if locale speci‐
101       fies a locale where langinfo data is not defined.
102
103       If item is not valid, a pointer to an empty string is returned.
104
105       The pointer returned by these functions may point to static  data  that
106       may be overwritten, or the pointer itself may be invalidated, by a sub‐
107       sequent call to nl_langinfo(), nl_langinfo_l(), or  setlocale(3).   The
108       same  statements apply to nl_langinfo_l() if the locale object referred
109       to by locale is freed or modified by freelocale(3) or newlocale(3).
110
111       POSIX specifies that the application may not modify the string returned
112       by these functions.
113

ATTRIBUTES

115       For   an   explanation   of   the  terms  used  in  this  section,  see
116       attributes(7).
117
118       ┌──────────────┬───────────────┬────────────────┐
119Interface     Attribute     Value          
120       ├──────────────┼───────────────┼────────────────┤
121nl_langinfo() │ Thread safety │ MT-Safe locale │
122       └──────────────┴───────────────┴────────────────┘

CONFORMING TO

124       POSIX.1-2001, POSIX.1-2008, SUSv2.
125

NOTES

127       The behavior of nl_langinfo_l() is undefined if locale is  the  special
128       locale object LC_GLOBAL_LOCALE or is not a valid locale object handle.
129

EXAMPLE

131       The  following  program  sets the character type and the numeric locale
132       according to the environment and queries the terminal character set and
133       the radix character.
134
135       #include <langinfo.h>
136       #include <locale.h>
137       #include <stdio.h>
138       #include <stdlib.h>
139
140       int
141       main(int argc, char *argv[])
142       {
143           setlocale(LC_CTYPE, "");
144           setlocale(LC_NUMERIC, "");
145
146           printf("%s\n", nl_langinfo(CODESET));
147           printf("%s\n", nl_langinfo(RADIXCHAR));
148
149           exit(EXIT_SUCCESS);
150       }
151

SEE ALSO

153       locale(1), localeconv(3), setlocale(3), charsets(7), locale(7)
154
155       The GNU C Library Reference Manual
156

COLOPHON

158       This  page  is  part of release 5.02 of the Linux man-pages project.  A
159       description of the project, information about reporting bugs,  and  the
160       latest     version     of     this    page,    can    be    found    at
161       https://www.kernel.org/doc/man-pages/.
162
163
164
165GNU                               2019-03-06                    NL_LANGINFO(3)
Impressum