⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setlocale.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!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-2003 The Open Group, All Rights Reserved --><title>setlocale</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="setlocale"></a> <a name="tag_03_655"></a><!-- setlocale --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_655_01"></a>NAME</h4><blockquote>setlocale - set program locale</blockquote><h4><a name="tag_03_655_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include &lt;<a href="../basedefs/locale.h.html">locale.h</a>&gt;<br><br> char *setlocale(int</tt> <i>category</i><tt>, const char *</tt><i>locale</i><tt>);<br></tt></code></p></blockquote><h4><a name="tag_03_655_03"></a>DESCRIPTION</h4><blockquote><div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"border="0"> The functionality described on this reference page is aligned with the ISO&nbsp;C standard. Any conflict between therequirements described here and the ISO&nbsp;C standard is unintentional. This volume of IEEE&nbsp;Std&nbsp;1003.1-2001 defers tothe ISO&nbsp;C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div><p>The <i>setlocale</i>() function selects the appropriate piece of the program's locale, as specified by the <i>category</i> and<i>locale</i> arguments, and may be used to change or query the program's entire locale or portions thereof. The value<i>LC_ALL</i> for <i>category</i> names the program's entire locale; other values for <i>category</i> name only a part of theprogram's locale:</p><dl compact><dt><i>LC_COLLATE</i></dt><dd>Affects the behavior of regular expressions and the collation functions.</dd><dt><i>LC_CTYPE</i></dt><dd>Affects the behavior of regular expressions, character classification, character conversion functions, and wide-characterfunctions.</dd><dt><i>LC_MESSAGES</i></dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Affects what strings are expected by commands and utilities as affirmative or negative responses. <img src="../images/opt-end.gif"alt="[Option End]" border="0"> <p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">It also affects what strings are given by commands and utilities as affirmative or negative responses, and the content of messages.<img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></dd><dt><i>LC_MONETARY</i></dt><dd>Affects the behavior of functions that handle monetary values.</dd><dt><i>LC_NUMERIC</i></dt><dd>Affects the behavior of functions that handle numeric values.</dd><dt><i>LC_TIME</i></dt><dd>Affects the behavior of the time conversion functions.</dd></dl><p>The <i>locale</i> argument is a pointer to a character string containing the required setting of <i>category</i>. The contentsof this string are implementation-defined. In addition, the following preset values of <i>locale</i> are defined for all settingsof <i>category</i>:</p><dl compact><dt>"POSIX"</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Specifies the minimal environment for C-language translation called the POSIX locale. If <i>setlocale</i>() is not invoked, thePOSIX locale is the default at entry to <i>main</i>(). <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>"C"</dt><dd>Equivalent to <tt>"POSIX"</tt> .</dd><dt>""</dt><dd>Specifies an implementation-defined native environment. <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;This corresponds to the value of the associated environmentvariables, <i>LC_*</i> and <i>LANG ;</i> see the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap07.html">Chapter 7, Locale</a> and the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap08.html">Chapter 8, Environment Variables</a>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>A&nbsp;null&nbsp;pointer</dt><dd>Used to direct <i>setlocale</i>() to query the current internationalized environment and return the name of the locale.</dd></dl><p><sup>[<a href="javascript:open_code('THR')">THR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The locale state is common to all threads within a process. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_03_655_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>setlocale</i>() shall return the string associated with the specified category for the newlocale. Otherwise, <i>setlocale</i>() shall return a null pointer and the program's locale is not changed.</p><p>A null pointer for <i>locale</i> causes <i>setlocale</i>() to return a pointer to the string associated with the <i>category</i>for the program's current locale. The program's locale shall not be changed.</p><p>The string returned by <i>setlocale</i>() is such that a subsequent call with that string and its associated <i>category</i>shall restore that part of the program's locale. The application shall not modify the string returned which may be overwritten by asubsequent call to <i>setlocale</i>().</p></blockquote><h4><a name="tag_03_655_05"></a>ERRORS</h4><blockquote><p>No errors are defined.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_655_06"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_655_07"></a>APPLICATION USAGE</h4><blockquote><p>The following code illustrates how a program can initialize the international environment for one language, while selectivelymodifying the program's locale such that regular expressions and string operations can be applied to text recorded in a differentlanguage:</p><pre><tt>setlocale(LC_ALL, "De");setlocale(LC_COLLATE, "Fr@dict");</tt></pre><p>Internationalized programs must call <i>setlocale</i>() to initiate a specific language operation. This can be done by calling<i>setlocale</i>() as follows:</p><pre><tt>setlocale(LC_ALL, "");</tt></pre><p>Changing the setting of <i>LC_MESSAGES</i> has no effect on catalogs that have already been opened by calls to <a href="../functions/catopen.html"><i>catopen</i>()</a>.</p></blockquote><h4><a name="tag_03_655_08"></a>RATIONALE</h4><blockquote><p>The ISO&nbsp;C standard defines a collection of functions to support internationalization. One of the most significant aspectsof these functions is a facility to set and query the <i>international environment</i>. The international environment is arepository of information that affects the behavior of certain functionality, namely:</p><ol><li><p>Character handling</p></li><li><p>Collating</p></li><li>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -