<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
	<id>https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Locale.h</id>
	<title>Locale.h - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Locale.h"/>
	<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Locale.h&amp;action=history"/>
	<updated>2026-07-15T18:34:45Z</updated>
	<subtitle>在这个wiki上该页的修订历史</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://arolstar52-zhtest.hf.space/index.php?title=Locale.h&amp;diff=1871091&amp;oldid=prev</id>
		<title>imported&gt;InternetArchiveBot：​补救5个来源，并将0个来源标记为失效。) #IABot (v2.0.8</title>
		<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Locale.h&amp;diff=1871091&amp;oldid=prev"/>
		<updated>2021-02-07T15:16:39Z</updated>

		<summary type="html">&lt;p&gt;补救5个来源，并将0个来源标记为失效。) #IABot (v2.0.8&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{noteTA&lt;br /&gt;
|G1=IT&lt;br /&gt;
|1=zh-hans:函数库; zh-hant:函式庫;&lt;br /&gt;
}}&lt;br /&gt;
{{C_Standard_library|nocat}} &amp;lt;!-- to edit this template go to [[template:C_Standard_library]] --&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;locale.h&amp;#039;&amp;#039;&amp;#039;是[[C程序设计语言]][[C標準函數庫|标准函数库]]的一个[[头文件]]，声明了&amp;#039;&amp;#039;&amp;#039;C语言[[本地化]]函数&amp;#039;&amp;#039;&amp;#039;。&amp;lt;ref name=&amp;quot;c99&amp;quot;&amp;gt;{{cite book | url=http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf | title=ISO/IEC 9899:1999 specification | at=p. 204, § 7.11 &amp;#039;&amp;#039;Localization&amp;#039;&amp;#039; | access-date=2012-09-02 | archive-date=2011-01-24 | archive-url=https://web.archive.org/web/20110124052108/http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf | dead-url=no }}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;c_primer&amp;quot;&amp;gt;{{cite book|title=C primer plus | first=Stephen | last=Prata | year=2004 | publisher=Sams Publishing | isbn=0-672-32696-5 | at=Appendix B, Section V: The Standard ANSI C Library with C99 Additions}}&amp;lt;/ref&amp;gt; 这些函数用于在处理多种自然语言的软件编程设计时，把程序调整到特定的[[区域设置]]. 这些区域设置影响到C语言标准库的[[stdio.h|输入/输出函数]].&lt;br /&gt;
&lt;br /&gt;
==所包含的函数==&lt;br /&gt;
&lt;br /&gt;
C语言本地化函数与数据类型定义在&amp;lt;tt&amp;gt;locale.h&amp;lt;/tt&amp;gt; (&amp;lt;tt&amp;gt;clocale&amp;lt;/tt&amp;gt;头文件用于C++).&amp;lt;ref name=www.utas.edu.au&amp;gt;{{cite web|title=locale.h|url=http://www.utas.edu.au/infosys/info/documentation/C/CStdLib.html#locale.h|work=utas.edu.au|publisher=infosys|accessdate=14 September 2011|archive-date=2012-06-04|archive-url=https://web.archive.org/web/20120604201614/http://www.utas.edu.au/infosys/info/documentation/C/CStdLib.html#locale.h|dead-url=no}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size:0.85em;&amp;quot;&lt;br /&gt;
! Function&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|setlocale}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/locale/setlocale setlocale]&amp;lt;/code&amp;gt; &lt;br /&gt;
| 设置与读取当前C locale&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|localeconv}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/locale/localeconv localeconv]&amp;lt;/code&amp;gt; &lt;br /&gt;
| 返回当前locale的货币与数值的格式细节&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==批评==&lt;br /&gt;
&lt;br /&gt;
C语言标准中定义的区域设置函数的最大问题是，区域设置状态是全局的。这意味着一个程序在一个时刻只能有一个locale设置。实现程序同时具有多个locale是非常困难的。&amp;lt;ref&amp;gt;{{cite web | title=The Standard C Locale and the Standard C++ Locales | url=http://www.math.hkbu.edu.hk/parallel/pgi/doc/pgC++_lib/stdlibug/sta_9169.htm | publisher=Rogue Wave Software, Inc. | year=1996 | accessdate=2012-09-02 | archive-date=2020-02-19 | archive-url=https://web.archive.org/web/20200219173855/http://www.math.hkbu.edu.hk/parallel/pgi/doc/pgC++_lib/stdlibug/sta_9169.htm | dead-url=no }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Visual C++]]运行时刻库定义了函数&amp;lt;code&amp;gt;_configthreadlocale&amp;lt;/code&amp;gt;&amp;lt;ref&amp;gt;{{Cite web |url=http://msdn.microsoft.com/en-us/library/26c0tb7x%28v=vs.100%29.aspx |title=Microsoft的MSDN上的相关帮助文章 |accessdate=2012-09-06 |archive-date=2016-05-19 |archive-url=https://web.archive.org/web/20160519172954/https://msdn.microsoft.com/en-us/library/26c0tb7x(v=vs.100).aspx |dead-url=no }}&amp;lt;/ref&amp;gt;，可以打开或者关闭[[线程]]相关区域设置（thread-specific locale）。另外一个运行时刻库函数&amp;lt;code&amp;gt;_setmbcp&amp;lt;/code&amp;gt;，在线程中创建限于本线程使用的区域设置数据结构。此后，就可以在该线程使用setlocale标准库函数了。但此种方法仅限于Windows平台。&lt;br /&gt;
&lt;br /&gt;
==例子==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;locale.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    /* Locale is set to &amp;quot;C&amp;quot; before this. This call sets it&lt;br /&gt;
       to the &amp;quot;current locale&amp;quot; by reading environment variables: */&lt;br /&gt;
    setlocale(LC_ALL, &amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    const struct lconv * const currentlocale = localeconv();&lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;In the current locale, the default currency symbol is: %s\n&amp;quot;,&lt;br /&gt;
        currentlocale-&amp;gt;currency_symbol);&lt;br /&gt;
&lt;br /&gt;
    return EXIT_SUCCESS;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==参考文献==&lt;br /&gt;
*[http://lh.2xlibre.net/ glibc中定义的各种locale的列表，包括了各种细节] {{Wayback|url=http://lh.2xlibre.net/ |date=20201124010001 }}&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
 &lt;br /&gt;
[[Category:C标准函式库]]&lt;/div&gt;</summary>
		<author><name>imported&gt;InternetArchiveBot</name></author>
	</entry>
</feed>