📄 locale.html
字号:
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; seethe Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap07.html#tag_07_03">Section 7.3, LocaleDefinition</a>.</p><p>Compound keyword values (list entries) shall be separated in the output by semicolons. When included in keyword values, thesemicolon, 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 isset to an unrecognized value, the actual locales assumed (if any) are implementation-defined as described in the Base Definitionsvolume 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 areavailable).</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_xLC_COLLATE=locale_y</tt></pre><p>The command <i>locale</i> would result in the following output:</p><pre><tt>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=</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_NUMERICdecimal_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 hereelse non-affirmative processing goes herefi</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 aquestionable value in having a shell script receive an entire array of characters. It is also difficult to return a logicalcollation 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 thecharmaps (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 onekeyword 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><p>IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/30 is applied, correcting an editorial error in the STDOUTsection.</p></blockquote><div class="box"><em>End of informative text.</em></div><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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -