📄 locale.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>locale</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_001_014_1175"> </a>NAME</h4><blockquote>locale - get locale-specific information</blockquote><h4><a name = "tag_001_014_1176"> </a>SYNOPSIS</h4><blockquote><pre><code>locale <b>[</b> -a| -m<b>]</b>locale <b>[</b>-ck<b>] </b><i>name</i>...</code></pre></blockquote><h4><a name = "tag_001_014_1177"> </a>DESCRIPTION</h4><blockquote>The<i>locale</i>utility writes 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 accessibleto the application.<p>When<i>locale</i>is invoked without any arguments, it summarises thecurrent locale environment for each locale category as determinedby the settings of the environment variables defined inthe <b>XBD</b> specification, <a href="../xbd/locale.html"><b>Locale</b> </a> .<p>When invoked with operands,it writes values that have beenassigned to the keywords in thelocale categories, as follows:<ul><p><li>Specifying a keyword name selects the named keyword and the categorycontaining that keyword.<p><li>Specifying a category name selects the named categoryand all keywords in that category.<p></ul></blockquote><h4><a name = "tag_001_014_1178"> </a>OPTIONS</h4><blockquote>The<i>locale</i>utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b> </a> .<p>The following options are supported:<dl compact><dt><b>-a</b><dd>Write information about all available public locales.The available locales include<b>POSIX</b>,representing the POSIX locale.The manner in which the implementation determines what otherlocales are availableis implementation-dependent.<dt><b>-c</b><dd>Write the names of selected locale categories;see the STDOUT section.The<b>-c</b>option increases readability when more than onecategory is selected (for example, via more than one keyword nameor via a category name).It is valid both with and without the<b>-k</b>option.<dt><b>-k</b><dd>Write the names and values of selected keywords.The implementation may omit values for some keywords;see the OPERANDS section.<dt><b>-m</b><dd>Write names of available charmaps;seethe <b>XBD</b> specification, <a href="../xbd/charset.html#tag_001_001"><b>Portable Character Set</b> </a> .</dl></blockquote><h4><a name = "tag_001_014_1179"> </a>OPERANDS</h4><blockquote>The following operand is supported:<dl compact><dt><i>name</i><dd>The name of a locale category as defined inthe <b>XBD</b> specification, <a href="../xbd/locale.html"><b>Locale</b> </a> ,the name of a keyword in a locale category,or the reserved name<b>charmap</b>.The named category or keyword will be selected for output.If a single<i>name</i>represents both a locale category name and a keyword namein the current locale, the results are unspecified.Otherwise, both category and keyword names can bespecified as<i>name</i>operands, in any sequence.It is implementation-dependent whether any keyword valuesare written for the categories LC_CTYPE and LC_COLLATE.</dl></blockquote><h4><a name = "tag_001_014_1180"> </a>STDIN</h4><blockquote>Not used.</blockquote><h4><a name = "tag_001_014_1181"> </a>INPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1182"> </a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables affect the execution of<i>locale</i>:<dl compact><dt><i>LANG</i><dd>Provide a default value for the internationalisation variablesthat are unset or null.If<i>LANG</i>is unset or null, the corresponding value from theimplementation-dependent default locale will be used.If any of the internationalisation variables contains an invalid setting, theutility will behave as if none of the variables had been defined.<dt><i>LC_ALL</i><dd>If set to a non-empty string value,override the values of all the other internationalisation variables.<dt><i>LC_CTYPE</i><dd>Determine thelocale for the interpretation of sequences of bytes of text data ascharacters (for example, single- as opposed to multi-byte charactersin arguments and input files).<dt><i>LC_MESSAGES</i><dd>Determine the locale that should be used to affectthe format and contents of diagnosticmessages written to standard error.<dt><i>NLSPATH</i><dd>Determine the location of message cataloguesfor the processing of<i>LC_MESSAGES .</i></dl><p>The<i>LANG ,</i><i>LC_*</i>and<i>NLSPATH</i>environment variables must specify the current locale environmentto be written out; they will be used if the<b>-a</b>option is not specified.</blockquote><h4><a name = "tag_001_014_1183"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_1184"> </a>STDOUT</h4><blockquote>If<i>locale</i>is invoked without any options or operands, the namesand values of the<i>LANG</i>and<i>LC_*</i>environment variables described in this specificationwill 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>will be written using this format:<p><code><tt>"%s=%s\n"</tt>, <<i>variable_name</i>>,<<i>value</i>></code><p>The names of those<i>LC_*</i>variables associated with locale categories defined in this specificationthat are not set in the environment or are overridden by<i>LC_ALL</i>will be written in the following format:<p><code><tt>"%s=\"%s\"\n"</tt>, <<i>variable_name</i>>,<<i>implied value</i>></code><p>The<<i>implied value</i>>is the name of the locale that has beenselected for that category by the implementation, based on the values in<i>LANG</i>and<i>LC_ALL ,</i>as described inthe <b>XBD</b> specification, <a href="../xbd/envvar.html"><b>Environment Variables</b> </a> .<p>The<<i>value</i>>and<<i>implied value</i>>shown abovewill be properly quoted for possible later reentry to the shell.The<<i>value</i>>will not be quoted using double-quotes (so that it can be distinguishedby the user from the<<i>implied value</i>>case, which always requires double-quotes).<p>The<i>LC_ALL</i>variable will be written last,using the first format shown above.If it is not set, it will be written as:<pre><code>"LC_ALL=\n"</code></pre><p>If any arguments are specified:<ol><p><li>If the<b>-a</b>option is specified, thenames of all the public locales will be written,each in the following format:<p><code><tt>"%s\n"</tt>, <<i>locale name</i>></code><p><li>If the<b>-c</b>option is specified, the names of all selected categorieswill be written, each in the following format:<p><code><tt>"%s\n"</tt>, <<i>category name</i>></code><p>If keywords are also selected for writing (see following items),the category name output will precede the keyword outputfor that category.<p>If the<b>-c</b>option is not specified, the names of the categorieswill not be written; only the keywords, as selected by the<i>name</i>operand, will be written.<p><li>If the<b>-k</b>option is specified, the names and valuesof selected keywords will be written.If a value is non-numeric,it will be written in the following format:<p><code>"%s=\"%s\"\n",<<i>keyword name</i>>,<<i>keyword value</i>></code><p>If the keyword was<b>charmap</b>,the name of the charmap (if any) that was specified via the<i><a href="localedef.html">localedef</a></i><b>-f</b>option when the locale was created will be written, with the word<b>charmap</b>as<<i>keyword name</i>>.<p>If a value is numeric,it will be written in one of the following formats:<p><code><tt>"%s=%d\n"</tt>, <<i>keyword name</i>>,<<i>keyword value</i>></code><p><code><pre><tt>"%s=%c%o\n"</tt>, <<i>keyword name</i>>,<<i>escape character</i>>,<<i>keyword value</i>></pre></code><p><code><pre><tt>"%s=%cx%x\n"</tt>, <<i>keyword name</i>>,<<i>escape character</i>>,<<i>keyword value</i>></pre></code>where the<<i>escape character</i>>is that identified by the<b>escape_char</b>keyword in the current locale; seethe <b>XBD</b> specification, <a href="../xbd/locale.html#tag_005_003"><b>Locale Definitions</b> </a> .<p>Compound keyword values (list entries) will be separatedin the output by semicolons.When included in keyword values, the semicolon,the double-quote, the backslash and any control characterwill be preceded (escaped) with the escape character.<p><li>If the<b>-k</b>option is not specified,selected keyword values will be written,each in the following format:<p><code><tt>"%s\n"</tt>, <<i>keyword value</i>></code><p>If the keyword was<b>charmap</b>,the name of the charmap (if any) that was specified via the<i><a href="localedef.html">localedef</a></i><b>-f</b>option when the locale was created will be written.<p><li>If the<b>-m</b>option is specified, then a list of all availablecharmaps will be written, each in the format:<p><code><pre><tt>"%s\n"</tt>, <<i>charmap</i>></pre></code>where<<i>charmap</i>>is in a format suitable for use as the option-argument to the<i><a href="localedef.html">localedef</a></i><b>-f</b>option.<p></ol></blockquote><h4><a name = "tag_001_014_1185"> </a>STDERR</h4><blockquote>Used only for diagnostic messages.</blockquote><h4><a name = "tag_001_014_1186"> </a>OUTPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1187"> </a>EXTENDED DESCRIPTION</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1188"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>All the requested information was found and output successfully.<dt>>0<dd>An error occurred.</dl></blockquote><h4><a name = "tag_001_014_1189"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_1190"> </a>APPLICATION USAGE</h4><blockquote>If the<i>LANG</i>environment variable is not set or set to an empty value, orone of the<i>LC_*</i>environment variables is set to an unrecognised value,the actual locales assumed (if any) are implementation-dependent asdescribed inthe <b>XBD</b> specification, <a href="../xbd/envvar.html"><b>Environment Variables</b> </a> .<p>Implementations are not required to write out the actual valuesfor keywords in the categories LC_CTYPE and LC_COLLATE; however,they must write out the categories (allowing an application to determine,for example, which character classes are available).</blockquote><h4><a name = "tag_001_014_1191"> </a>EXAMPLES</h4><blockquote>In the following examples, the assumption is that locale environmentvariables are set as follows:<pre><code>LANG=locale_xLC_COLLATE=locale_y</code></pre><p>The command:<pre><code>locale</code></pre>would result in the following output:<pre><code>LANG=locale_xLC_CTYPE="locale_x"LC_COLLATE=locale_yLC_TIME="locale_x"LC_NUMERIC="locale_x"LC_MONETARY="locale_x"LC_MESSAGES="locale_x"LC_ALL=</code></pre><p>The order of presentation of the categoriesis not specified by this specification.<p>The command:<pre><code>LC_ALL=POSIX locale -ck decimal_point</code></pre>would produce:<pre><code>LC_NUMERICdecimal_point="."</code></pre><p>The following command shows an application of<i>locale</i>to determine whether a user-supplied response is affirmative:<pre><code>if printf "%s\n" "$response" | grep -Eq "$(locale yesexpr)"then affirmative processing goes hereelse non-affirmative processing goes herefi</code></pre></blockquote><h4><a name = "tag_001_014_1192"> </a>FUTURE DIRECTIONS</h4><blockquote>The IEEE PASC 1003.2 Interpretations Committee has forwarded concerns aboutparts of this interface definition to the IEEE PASC Shell and Utilities Working Groupwhich is identifying the corrections.A future revision of this specification will align withIEEE Std. 1003.2b when finalised.</blockquote><h4><a name = "tag_001_014_1193"> </a>SEE ALSO</h4><blockquote><i><a href="localedef.html">localedef</a></i>,the <b>XBD</b> specification, <a href="../xbd/locale.html#tag_005_003"><b>Locale Definitions</b> </a> .</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -