2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml">
5 <title>I18N::Langinfo - query locale information
</title>
6 <meta http-equiv=
"content-type" content=
"text/html; charset=utf-8" />
7 <link rev=
"made" href=
"mailto:" />
10 <body style=
"background-color: white">
11 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
12 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
13 <big><strong><span class=
"block"> I18N::Langinfo - query locale information
</span></strong></big>
17 <p><a name=
"__index__"></a></p>
22 <li><a href=
"#name">NAME
</a></li>
23 <li><a href=
"#synopsis">SYNOPSIS
</a></li>
24 <li><a href=
"#description">DESCRIPTION
</a></li>
27 <li><a href=
"#export">EXPORT
</a></li>
30 <li><a href=
"#see_also">SEE ALSO
</a></li>
31 <li><a href=
"#author">AUTHOR
</a></li>
32 <li><a href=
"#copyright_and_license">COPYRIGHT AND LICENSE
</a></li>
39 <h1><a name=
"name">NAME
</a></h1>
40 <p>I18N::Langinfo - query locale information
</p>
44 <h1><a name=
"synopsis">SYNOPSIS
</a></h1>
46 use I18N::Langinfo;
</pre>
50 <h1><a name=
"description">DESCRIPTION
</a></h1>
51 <p>The
<code>langinfo()
</code> function queries various locale information that can be
52 used to localize output and user interfaces. The
<code>langinfo()
</code> requires
53 one numeric argument that identifies the locale constant to query:
54 if no argument is supplied,
<a href=
"file://C|\msysgit\mingw\html/pod/perlvar.html#item___"><code>$_
</code></a> is used. The numeric constants
55 appropriate to be used as arguments are exportable from I18N::Langinfo.
</p>
56 <p>The following example will import the
<code>langinfo()
</code> function itself and
57 three constants to be used as arguments to langinfo(): a constant for
58 the abbreviated first day of the week (the numbering starts from
59 Sunday =
1) and two more constants for the affirmative and negative
60 answers for a yes/no question in the current locale.
</p>
62 use I18N::Langinfo qw(langinfo ABDAY_1 YESSTR NOSTR);
</pre>
64 my ($abday_1, $yesstr, $nostr) = map { langinfo } qw(ABDAY_1 YESSTR NOSTR);
</pre>
66 print
"$abday_1? [$yesstr/$nostr]
";
</pre>
67 <p>In other words, in the ``C'' (or English) locale the above will probably
68 print something like:
</p>
71 <p>but under a French locale
</p>
74 <p>The usually available constants are
</p>
76 ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5 ABDAY_6 ABDAY_7
77 ABMON_1 ABMON_2 ABMON_3 ABMON_4 ABMON_5 ABMON_6
78 ABMON_7 ABMON_8 ABMON_9 ABMON_10 ABMON_11 ABMON_12
79 DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7
80 MON_1 MON_2 MON_3 MON_4 MON_5 MON_6
81 MON_7 MON_8 MON_9 MON_10 MON_11 MON_12
</pre>
82 <p>for abbreviated and full length days of the week and months of the year,
</p>
84 D_T_FMT D_FMT T_FMT
</pre>
85 <p>for the date-time, date, and time formats used by the
<code>strftime()
</code> function
86 (see
<a href=
"file://C|\msysgit\mingw\html/lib/POSIX.html">the POSIX manpage
</a>)
</p>
88 AM_STR PM_STR T_FMT_AMPM
</pre>
89 <p>for the locales for which it makes sense to have ante meridiem and post
90 meridiem time formats,
</p>
92 CODESET CRNCYSTR RADIXCHAR
</pre>
93 <p>for the character code set being used (such as ``ISO8859-
1'', ``cp850'',
94 ``koi8-r'', ``sjis'', ``utf8'', etc.), for the currency string, for the
95 radix character used between the integer and the fractional part
96 of decimal numbers (yes, this is redundant with POSIX::localeconv())
</p>
98 YESSTR YESEXPR NOSTR NOEXPR
</pre>
99 <p>for the affirmative and negative responses and expressions, and
</p>
101 ERA ERA_D_FMT ERA_D_T_FMT ERA_T_FMT
</pre>
102 <p>for the Japanese Emperor eras (naturally only defined under Japanese locales).
</p>
103 <p>See your
<em>langinfo(
3)
</em> for more information about the available
104 constants. (Often this means having to look directly at the
105 <em>langinfo.h
</em> C header file.)
</p>
106 <p>Note that unfortunately none of the above constants are guaranteed
107 to be available on a particular platform. To be on the safe side
108 you can wrap the import in an eval like this:
</p>
111 require I18N::Langinfo;
112 I18N::Langinfo-
>import(qw(langinfo CODESET));
113 $codeset = langinfo(CODESET()); # note the ()
115 if (!$@) { ... failed ... }
</pre>
118 <h2><a name=
"export">EXPORT
</a></h2>
119 <p>Nothing is exported by default.
</p>
123 <h1><a name=
"see_also">SEE ALSO
</a></h1>
124 <p><a href=
"file://C|\msysgit\mingw\html/pod/perllocale.html">the perllocale manpage
</a>,
<a href=
"file://C|\msysgit\mingw\html/lib/auto/POSIX/localeconv.html">localeconv in the POSIX manpage
</a>,
<a href=
"file://C|\msysgit\mingw\html/lib/auto/POSIX/setlocale.html">setlocale in the POSIX manpage
</a>,
<em>nl_langinfo(
3)
</em>.
</p>
125 <p>The
<code>langinfo()
</code> is just a wrapper for the C
<code>nl_langinfo()
</code> interface.
</p>
129 <h1><a name=
"author">AUTHOR
</a></h1>
130 <p>Jarkko Hietaniemi,
<<a href=
"mailto:jhi@hut.fi">jhi@hut.fi
</a>></p>
134 <h1><a name=
"copyright_and_license">COPYRIGHT AND LICENSE
</a></h1>
135 <p>Copyright
2001 by Jarkko Hietaniemi
</p>
136 <p>This library is free software; you can redistribute it and/or modify
137 it under the same terms as Perl itself.
</p>
138 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
139 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
140 <big><strong><span class=
"block"> I18N::Langinfo - query locale information
</span></strong></big>