463 lines
16 KiB
HTML
463 lines
16 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>locale</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="locale"></a> <a name="tag_04_76"></a><!-- locale -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_04_76_01"></a>NAME</h4>
|
|
|
|
<blockquote>locale - get locale-specific information</blockquote>
|
|
|
|
<h4><a name="tag_04_76_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><code><tt>locale</tt> <b>[</b><tt>-a| -m</tt><b>]</b><tt><br>
|
|
<br>
|
|
locale</tt> <b>[</b><tt>-ck</tt><b>]</b> <i>name</i><tt>...<br>
|
|
</tt></code></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>locale</i> utility shall write information about the current locale environment, or all public locales, to the standard
|
|
output. For the purposes of this section, a <i>public locale</i> is one provided by the implementation that is accessible to the
|
|
application.</p>
|
|
|
|
<p>When <i>locale</i> is invoked without any arguments, it shall summarize the current locale environment for each locale category
|
|
as determined by the settings of the environment variables defined in the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap07.html">Chapter 7, Locale</a>.</p>
|
|
|
|
<p>When invoked with operands, it shall write values that have been assigned to the keywords in the locale categories, as
|
|
follows:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>Specifying a keyword name shall select the named keyword and the category containing that keyword.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Specifying a category name shall select the named category and all keywords in that category.</p>
|
|
</li>
|
|
</ul>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_04"></a>OPTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>locale</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p>
|
|
|
|
<p>The following options shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><b>-a</b></dt>
|
|
|
|
<dd>Write information about all available public locales. The available locales shall include <b>POSIX</b>, representing the POSIX
|
|
locale. The manner in which the implementation determines what other locales are available is implementation-defined.</dd>
|
|
|
|
<dt><b>-c</b></dt>
|
|
|
|
<dd>Write the names of selected locale categories; see the STDOUT section. The <b>-c</b> option increases readability when more
|
|
than one category is selected (for example, via more than one keyword name or via a category name). It is valid both with and
|
|
without the <b>-k</b> option.</dd>
|
|
|
|
<dt><b>-k</b></dt>
|
|
|
|
<dd>Write the names and values of selected keywords. The implementation may omit values for some keywords; see the OPERANDS
|
|
section.</dd>
|
|
|
|
<dt><b>-m</b></dt>
|
|
|
|
<dd>Write names of available charmaps; see the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap06.html#tag_06_01">Section 6.1, Portable Character Set</a>.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_05"></a>OPERANDS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following operand shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>name</i></dt>
|
|
|
|
<dd>The name of a locale category as defined in the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap07.html">Chapter 7, Locale</a>, the name of a keyword in a locale category, or the reserved name
|
|
<b>charmap</b>. The named category or keyword shall be selected for output. If a single <i>name</i> represents both a locale
|
|
category name and a keyword name in the current locale, the results are unspecified. Otherwise, both category and keyword names can
|
|
be specified as <i>name</i> operands, in any sequence. It is implementation-defined whether any keyword values are written for the
|
|
categories <i>LC_CTYPE</i> and <i>LC_COLLATE .</i></dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_06"></a>STDIN</h4>
|
|
|
|
<blockquote>
|
|
<p>Not used.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_07"></a>INPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_08"></a>ENVIRONMENT VARIABLES</h4>
|
|
|
|
<blockquote>
|
|
<p>The following environment variables shall affect the execution of <i>locale</i>:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>LANG</i></dt>
|
|
|
|
<dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
|
|
the precedence of internationalization variables used to determine the values of locale categories.)</dd>
|
|
|
|
<dt><i>LC_ALL</i></dt>
|
|
|
|
<dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
|
|
|
|
<dt><i>LC_CTYPE</i></dt>
|
|
|
|
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
|
|
opposed to multi-byte characters in arguments and input files).</dd>
|
|
|
|
<dt><i>LC_MESSAGES</i></dt>
|
|
|
|
<dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard
|
|
error.</dd>
|
|
|
|
<dt><i>NLSPATH</i></dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></dd>
|
|
</dl>
|
|
|
|
<p>The application shall ensure that the <i>LANG ,</i> <i>LC_* ,</i> and <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup>
|
|
<img src="../images/opt-start.gif" alt="[Option Start]" border="0"> <i>NLSPATH</i> <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"> environment variables specify the current locale environment to be written out; they shall be used if
|
|
the <b>-a</b> option is not specified.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_09"></a>ASYNCHRONOUS EVENTS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_10"></a>STDOUT</h4>
|
|
|
|
<blockquote>
|
|
<p>If <i>locale</i> is invoked without any options or operands, the names and values of the <i>LANG</i> and <i>LC_*</i> environment
|
|
variables described in this volume of IEEE Std 1003.1-2001 shall be written to the standard output, one variable per
|
|
line, with <i>LANG</i> first, and each line using the following format. Only those variables set in the environment and not
|
|
overridden by <i>LC_ALL</i> shall be written using this format:</p>
|
|
|
|
<pre>
|
|
<tt>"%s=%s\n", <</tt><i>variable_name</i><tt>>, <</tt><i>value</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The names of those <i>LC_*</i> variables associated with locale categories defined in this volume of
|
|
IEEE Std 1003.1-2001 that are not set in the environment or are overridden by <i>LC_ALL</i> shall be written in the
|
|
following format:</p>
|
|
|
|
<pre>
|
|
<tt>"%s=\""%s\""\n", <</tt><i>variable_name</i><tt>>, <</tt><i>implied value</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The <<i>implied value</i>> shall be the name of the locale that has been selected for that category by the
|
|
implementation, based on the values in <i>LANG</i> and <i>LC_ALL ,</i> as described in the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html">Chapter 8, Environment Variables</a>.</p>
|
|
|
|
<p>The <<i>value</i>> and <<i>implied value</i>> shown above shall be properly quoted for possible later reentry
|
|
to the shell. The <<i>value</i>> shall not be quoted using double-quotes (so that it can be distinguished by the user from
|
|
the <<i>implied value</i>> case, which always requires double-quotes).</p>
|
|
|
|
<p>The <i>LC_ALL</i> variable shall be written last, using the first format shown above. If it is not set, it shall be written
|
|
as:</p>
|
|
|
|
<pre>
|
|
<tt>"LC_ALL=\n"
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If any arguments are specified:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If the <b>-a</b> option is specified, the names of all the public locales shall be written, each in the following format:</p>
|
|
|
|
<pre>
|
|
<tt>"%s\n", <</tt><i>locale name</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the <b>-c</b> option is specified, the names of all selected categories shall be written, each in the following format:</p>
|
|
|
|
<pre>
|
|
<tt>"%s\n", <</tt><i>category name</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If keywords are also selected for writing (see following items), the category name output shall precede the keyword output for
|
|
that category.</p>
|
|
|
|
<p>If the <b>-c</b> option is not specified, the names of the categories shall not be written; only the keywords, as selected by
|
|
the <<i>name</i>> operand, shall be written.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the <b>-k</b> option is specified, the names and values of selected keywords shall be written. If a value is non-numeric, it
|
|
shall be written in the following format:</p>
|
|
|
|
<pre>
|
|
<tt>"%s=\"%s\"\n", <</tt><i>keyword name</i><tt>>, <</tt><i>keyword value</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If the keyword was <b>charmap</b>, the name of the charmap (if any) that was specified via the <a href=
|
|
"../utilities/localedef.html"><i>localedef</i></a> <b>-f</b> option when the locale was created shall be written, with the word
|
|
<b>charmap</b> as <<i>keyword name</i>>.</p>
|
|
|
|
<p>If a value is numeric, it shall be written in one of the following formats:</p>
|
|
|
|
<pre>
|
|
<tt>"%s=%d\n", <</tt><i>keyword name</i><tt>>, <</tt><i>keyword value</i><tt>>
|
|
<br>
|
|
"%s=%c%o\n", <</tt><i>keyword name</i><tt>>, <</tt><i>escape character</i><tt>>, <</tt><i>keyword value</i><tt>>
|
|
<br>
|
|
"%s=%cx%x\n", <</tt><i>keyword name</i><tt>>, <</tt><i>escape character</i><tt>>, <</tt><i>keyword value</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>where the <<i>escape character</i>> is that identified by the <b>escape_char</b> keyword in the current locale; see
|
|
the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap07.html#tag_07_03">Section 7.3, Locale
|
|
Definition</a>.</p>
|
|
|
|
<p>Compound keyword values (list entries) shall be separated in the output by semicolons. When included in keyword values, the
|
|
semicolon, the double-quote, the backslash, and any control character shall be preceded (escaped) with the escape character.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the <b>-k</b> option is not specified, selected keyword values shall be written, each in the following format:</p>
|
|
|
|
<pre>
|
|
<tt>"%s\n", <</tt><i>keyword value</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If the keyword was <b>charmap</b>, the name of the charmap (if any) that was specified via the <a href=
|
|
"../utilities/localedef.html"><i>localedef</i></a> <b>-f</b> option when the locale was created shall be written.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the <b>-m</b> option is specified, then a list of all available charmaps shall be written, each in the format:</p>
|
|
|
|
<pre>
|
|
<tt>"%s\n", <</tt><i>charmap</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>where <<i>charmap</i>> is in a format suitable for use as the option-argument to the <a href=
|
|
"../utilities/localedef.html"><i>localedef</i></a> <b>-f</b> option.</p>
|
|
</li>
|
|
</ol>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_11"></a>STDERR</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard error shall be used only for diagnostic messages.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_12"></a>OUTPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_13"></a>EXTENDED DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_14"></a>EXIT STATUS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following exit values shall be returned:</p>
|
|
|
|
<dl compact>
|
|
<dt> 0</dt>
|
|
|
|
<dd>All the requested information was found and output successfully.</dd>
|
|
|
|
<dt>>0</dt>
|
|
|
|
<dd>An error occurred.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_15"></a>CONSEQUENCES OF ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_04_76_16"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>If the <i>LANG</i> environment variable is not set or set to an empty value, or one of the <i>LC_*</i> environment variables is
|
|
set to an unrecognized value, the actual locales assumed (if any) are implementation-defined as described in the Base Definitions
|
|
volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html">Chapter 8, Environment Variables</a>.</p>
|
|
|
|
<p>Implementations are not required to write out the actual values for keywords in the categories <i>LC_CTYPE</i> and <i>LC_COLLATE
|
|
;</i> however, they must write out the categories (allowing an application to determine, for example, which character classes are
|
|
available).</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_17"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>In the following examples, the assumption is that locale environment variables are set as follows:</p>
|
|
|
|
<pre>
|
|
<tt>LANG=locale_x
|
|
LC_COLLATE=locale_y
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The command <i>locale</i> would result in the following output:</p>
|
|
|
|
<pre>
|
|
<tt>LANG=locale_x
|
|
LC_CTYPE="locale_x"
|
|
LC_COLLATE=locale_y
|
|
LC_TIME="locale_x"
|
|
LC_NUMERIC="locale_x"
|
|
LC_MONETARY="locale_x"
|
|
LC_MESSAGES="locale_x"
|
|
LC_ALL=
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The order of presentation of the categories is not specified by this volume of IEEE Std 1003.1-2001.</p>
|
|
|
|
<p>The command:</p>
|
|
|
|
<pre>
|
|
<tt>LC_ALL=POSIX locale -ck decimal_point
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>would produce:</p>
|
|
|
|
<pre>
|
|
<tt>LC_NUMERIC
|
|
decimal_point="."
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The following command shows an application of <i>locale</i> to determine whether a user-supplied response is affirmative:</p>
|
|
|
|
<pre>
|
|
<tt>if printf "%s\n" "$response" | grep -Eq "$(locale yesexpr)"
|
|
then
|
|
affirmative processing goes here
|
|
else
|
|
non-affirmative processing goes here
|
|
fi
|
|
</tt>
|
|
</pre>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_18"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>The output for categories <i>LC_CTYPE</i> and <i>LC_COLLATE</i> has been made implementation-defined because there is a
|
|
questionable value in having a shell script receive an entire array of characters. It is also difficult to return a logical
|
|
collation description, short of returning a complete <a href="../utilities/localedef.html"><i>localedef</i></a> source.</p>
|
|
|
|
<p>The <b>-m</b> option was included to allow applications to query for the existence of charmaps. The output is a list of the
|
|
charmaps (implementation-supplied and user-supplied, if any) on the system.</p>
|
|
|
|
<p>The <b>-c</b> option was included for readability when more than one category is selected (for example, via more than one
|
|
keyword name or via a category name). It is valid both with and without the <b>-k</b> option.</p>
|
|
|
|
<p>The <b>charmap</b> keyword, which returns the name of the charmap (if any) that was used when the current locale was created,
|
|
was included to allow applications needing the information to retrieve it.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_19"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_20"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="localedef.html"><i>localedef</i></a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap07.html#tag_07_03">Section 7.3, Locale Definition</a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_21"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 4.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_22"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>The FUTURE DIRECTIONS section is added.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_76_23"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>The normative text is reworded to avoid use of the term "must" for application requirements.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|