1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\" and Copyright 1999 by Bruno Haible (haible@clisp.cons.org)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" Modified Sat Jul 24 18:20:12 1993 by Rik Faith (faith@cs.unc.edu)
25 .\" Modified Tue Jul 15 16:49:10 1997 by Andries Brouwer (aeb@cwi.nl)
26 .\" Modified Sun Jul 4 14:52:16 1999 by Bruno Haible (haible@clisp.cons.org)
27 .\" Modified Tue Aug 24 17:11:01 1999 by Andries Brouwer (aeb@cwi.nl)
28 .\" Modified Tue Feb 6 03:31:55 2001 by Andries Brouwer (aeb@cwi.nl)
30 .\" Japanese Version Copyright (c) 1998 Tanoshima Hidetohsi
31 .\" all rights reserved.
32 .\" Translated May 29 1998, Tanoshima Hidetoshi <tano@sainet.or.jp>
33 .\" Modified Mon Oct 2 11:09:18 JST 2000
34 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
35 .\" Updated Fri May 4 01:49:48 JST 2001
36 .\" by Kentaro Shirakata <argrath@ub32.org>
37 .\" Updated Sat Oct 12 2002 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
39 .\"WORD: locale ¥í¥±¡¼¥ë
40 .\"WORD: portable ¸ß´¹À¤Î¤¢¤ë
41 .\"WORD: regular expression Àµµ¬É½¸½
42 .\"WORD: range expressions ÈÏ°Ïɽ¸½
43 .\"WORD: equivalence classes Åù²Á¥¯¥é¥¹
44 .\"WORD: collation ¾È¹ç
45 .\"WORD: multibyte character ¿¥Ð¥¤¥Èʸ»ú
46 .\"WORD: wide character ¥ï¥¤¥Éʸ»ú
47 .\"WORD: opaque string ÆâÉôʸ»úÎó
49 .TH SETLOCALE 3 2008-12-05 "GNU" "Linux Programmer's Manual"
51 .\"O setlocale \- set the current locale
52 setlocale \- ¸½ºß¤Î¥í¥±¡¼¥ë (locale) ¤òÀßÄꤹ¤ë
55 .B #include <locale.h>
57 .BI "char *setlocale(int " category ", const char *" locale );
61 .\"O function is used to set or query the program's current locale.
63 ´Ø¿ô¤Ï¥×¥í¥°¥é¥à¤Î¥«¥ì¥ó¥È¥í¥±¡¼¥ë¤òÀßÄꤷ¤¿¤ê
64 Ì䤤¹ç¤ï¤»¤¿¤ê¤¹¤ë¤Î¤ËÍѤ¤¤é¤ì¤ë¡£
69 .\"O the program's current locale is modified according to the arguments.
71 ¤¬ NULL ¤Ç¤Ê¤±¤ì¤Ð¡¢¥×¥í¥°¥é¥à¤Î¥«¥ì¥ó¥È¥í¥±¡¼¥ë¤Ï°ú¤¿ô¤Ë½¾¤Ã¤ÆÊѹ¹¤µ¤ì¤ë¡£
74 .\"O determines which parts of the program's current locale should be modified.
77 ¤Ï¥×¥í¥°¥é¥à¤Î¥«¥ì¥ó¥È¥í¥±¡¼¥ë¤Î¤É¤ÎÉôʬ¤òÊѹ¹¤¹¤ë¤«¤ò·è¤á¤ë¡£
80 .\"O for all of the locale.
84 .\"O for regular expression matching (it determines the meaning
85 .\"O of range expressions and equivalence classes) and string collation.
86 Àµµ¬É½¸½¤Î¥Þ¥Ã¥Á¥ó¥° (ÈÏ°Ïɽ¸½¤ÈÅù²Á¥¯¥é¥¹¤Î¥Þ¥Ã¥Á¥ó¥°¤ò·èÄꤹ¤ë)
87 ¤Èʸ»úÎó¤Î¾È¹ç (collation)
90 .\"O for regular expression matching, character classification, conversion,
91 .\"O case-sensitive comparison, and wide character functions.
92 Àµµ¬É½¸½¤Î¥Þ¥Ã¥Á¥ó¥°¡¢Ê¸»ú¤ÎʬÎࡢʸ»ú¤ÎÊÑ´¹¡¢Âçʸ»ú¾®Ê¸»úÈæ³Ó¡¢
96 .\"O for localizable natural-language messages.
97 ÃÏ°è²½²Äǽ¤Ê¼«Á³¸À¸ì¥á¥Ã¥»¡¼¥¸
100 .\"O for monetary formatting.
104 .\"O for number formatting (such as the decimal point and the thousands separator).
105 ¿ôÃͤνñ¼° (¾®¿ôÅÀ¤ä 3 ·å¤´¤È¤Î¶èÀÚ¤ê)
108 .\"O for time and date formatting.
113 .\"O is a pointer to a character string containing the
114 .\"O required setting of
120 ¤ËÀßÄꤹ¤ëʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
121 .\"O Such a string is either a well-known constant like "C" or "da_DK"
122 .\"O (see below), or an opaque string that was returned by another call of
123 .\"O .BR setlocale ().
124 ¤³¤Îʸ»úÎó¤Ï¤è¤¯ÃΤé¤ì¤¿Äê¿ô¤Ç¤¢¤ë "C" ¤ä "da_DK" ¤Ê¤É¤Ç¤âÎɤ¤¤·
125 (°Ê²¼¤ò»²¾È)¡¢Â¾¤Î¤È¤¤Ë
127 ¤ò¸Æ¤Ó½Ð¤·¤¿ºÝ¤ËÊÖ¤µ¤ì¤¿¡¢ÆâÉôÍѤÎʸ»úÎó¤Ç¤âÎɤ¤¡£
133 .\"O each part of the locale that should be modified is set according to the
134 .\"O environment variables.
135 .\"O The details are implementation-dependent.
137 ¤¬ \fB""\fP ¤Î¾ì¹ç¡¢¥í¥±¡¼¥ë¤Î³ÆÉôʬ¤ÎÀßÄê¤Ë¤Ï´Ä¶ÊÑ¿ô¤¬»²¾È¤µ¤ì¤ë¡£
138 ¤½¤Î¾ÜºÙ¤Ï¼ÂÁõ°Í¸¤Ç¤¢¤ë¡£
139 .\"O For glibc, first (regardless of
141 .\"O the environment variable
144 .\"O next the environment variable with the same name as the category
145 .\"O .RB ( LC_COLLATE ,
147 .\"O .BR LC_MESSAGES ,
148 .\"O .BR LC_MONETARY ,
149 .\"O .BR LC_NUMERIC ,
151 .\"O and finally the environment variable
153 .\"O The first existing environment variable is used.
154 .\"O If its value is not a valid locale specification, the locale
155 .\"O is unchanged, and
156 .\"O .BR setlocale ()
158 glibc ¤Î¾ì¹ç¡¢¤Þ¤ººÇ½é¤Ë (¤É¤ó¤Ê
163 ¼¡¤Ë¥«¥Æ¥´¥ê (category) ¤ÈƱ¤¸Ì¾Á°¤Î´Ä¶ÊÑ¿ô
170 ¤¬¸¡ºº¤µ¤ì¡¢ºÇ¸å¤Ë´Ä¶ÊÑ¿ô
173 ºÇ½é¤Ë¸«¤Ä¤«¤Ã¤¿´Ä¶ÊÑ¿ô¤ò»ÈÍѤ¹¤ë¡£
174 ¤½¤ÎÃͤ¬¥í¥±¡¼¥ë»ØÄê¤È¤·¤ÆÀµ¤·¤¯¤Ê¤±¤ì¤Ð¡¢¥í¥±¡¼¥ë¤ÏÊѹ¹¤µ¤ì¤º¡¢
182 .\"O is a portable locale; its
184 .\"O part corresponds to the 7-bit ASCII
186 \fB"C"\fP ¥í¥±¡¼¥ë¤ä \fB"POSIX"\fP ¥í¥±¡¼¥ë¤Ï¸ß´¹À¤Î¤¢¤ë¥í¥±¡¼¥ë¤Ç¤¢¤ë¡£
189 ¤ÎÉôʬ¤Ï 7 ¥Ó¥Ã¥È ASCII ʸ»ú½¸¹ç¤ËÁêÅö¤·¤Æ¤¤¤ë¡£
191 .\"O A locale name is typically of the form
192 .\"O .IR language "[_" territory "][." codeset "][@" modifier "],"
195 .\"O is an ISO 639 language code,
197 .\"O is an ISO 3166 country code, and
199 .\"O is a character set or encoding identifier like
203 ¥í¥±¡¼¥ë̾¤Î½ñ¼°¤Ï¡¢Ä̾ï
204 .IR language "[_" territory "][." codeset "][@" modifier "]"
208 ¤Ï ISO 639 ¤Î¸À¸ì¥³¡¼¥É¤Ç¤¢¤ë¡£
210 ¤Ï ISO 3166 ¤Î¹ñ̾¥³¡¼¥É¤Ç¤¢¤ë¡£
216 ¤Î¤è¤¦¤Êʸ»ú½¸¹ç¤äʸ»úÉä¹æ²½¼±Ê̻ҤǤ¢¤ë¡£
217 .\"O For a list of all supported locales, try "locale \-a", cf.\&
219 ¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¥í¥±¡¼¥ë¤Î°ìÍ÷¤òÆÀ¤ë¤Ë¤Ï¡¢
220 "locale \-a" ¤ò¼Â¹Ô¤·¤Æ¤ß¤è
226 .\"O is NULL, the current locale is only queried, not modified.
228 ¤¬ NULL ¤Ê¤é¤Ð¡¢¸½ºß¤Î¥í¥±¡¼¥ë¤òÌ䤤¹ç¤ï¤»¤ë¤Î¤ß¤ÇÊѹ¹¤Ï¤·¤Ê¤¤¡£
230 .\"O On startup of the main program, the portable
232 .\"O locale is selected as default.
233 main ¥×¥í¥°¥é¥à¤Îµ¯Æ°»þ¤Ë¤Ï¡¢
234 ¸ß´¹À¤Î¤¢¤ë \fB"C"\fP ¥í¥±¡¼¥ë¤¬¥Ç¥Õ¥©¥ë¥È¤ÇÁªÂò¤µ¤ì¤ë¡£
235 .\"O A program may be made portable to all locales by calling:
238 .\"O setlocale(LC_ALL, "");
241 .\"O after program initialization, by using the values returned
243 .\"O .BR localeconv (3)
245 .\"O for locale-dependent information, by using the multibyte and wide
246 .\"O character functions for text processing if
247 .\"O .BR "MB_CUR_MAX > 1" ,
249 .\"O .BR strcoll (3),
252 .\"O .BR strxfrm (3),
254 .\"O to compare strings.
255 ¥×¥í¥°¥é¥à¤ò¤¹¤Ù¤Æ¤Î¥í¥±¡¼¥ë¤ËÂФ·¤Æ¸ß´¹¤Ë¤·¤¿¤±¤ì¤Ð¡¢
256 ¥×¥í¥°¥é¥à¤Î½é´ü²½¤Î¸å¤Ë
259 setlocale(LC_ALL, "");
262 ¤ò¸Æ¤Ó½Ð¤·¡¢¥í¥±¡¼¥ë°Í¸¤Î¾ðÊó¤Ë¤Ï
266 ¤Î¾ì¹ç¤Ë¤Ïʸ»úÎó¤ÎÁàºî¤Ë¤Ï¿¥Ð¥¤¥Èʸ»ú¡¢¥ï¥¤¥Éʸ»ú´Ø¿ô¤ò»ÈÍѤ·¡¢
275 .\"O A successful call to
276 .\"O .BR setlocale ()
277 .\"O returns an opaque string that corresponds to the locale set.
278 .\"O This string may be allocated in static storage.
279 .\"O The string returned is such that a subsequent call with that string
280 .\"O and its associated category will restore that part of the process's
282 .\"O The return value is NULL if the request cannot be honored.
284 ¤Î¸Æ¤Ó½Ð¤·¤ËÀ®¸ù¤¹¤ë¤È¡¢
285 ¤½¤Î¥í¥±¡¼¥ë½¸¹ç¤ËÂбþ¤¹¤ëÆâÉôʸ»úÎó (opaque string) ¤òÊÖ¤¹¡£
286 ¤³¤Îʸ»úÎó¤ÏÀÅŪ¤Êµ²±°è¤Ë³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
287 ¤³¤ÎÊ֤äÆÍ褿ʸ»úÎó¤ò¡¢¥«¥Æ¥´¥ê»ØÄê¤È¶¦¤Ë¡¢
288 ¤Î¤Á¤Î setlocale ¤Î¸Æ¤Ó½Ð¤·¤Ë»ØÄꤹ¤ì¤Ð¡¢
289 ¥×¥í¥»¥¹¤Î¤½¤ÎÉôʬ¤Î¥í¥±¡¼¥ë¤¬Éü¸µ¤µ¤ì¤ë¡£
290 ÀßÄê¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¤Ë¤Ï¡¢ÊÖ¤êÃÍ¤Ï NULL ¤Ë¤Ê¤ë¡£
292 C89, C99, POSIX.1-2001.
294 .\"O Linux (that is, glibc) supports the portable locales
295 Linux (¤È¤¤¤¦¤« glibc) ¤Ï¸ß´¹À¤Î¤¢¤ë¥í¥±¡¼¥ë¤È¤·¤Æ
296 \fB"C"\fP ¤È \fB"POSIX"\fP ¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¡£
297 .\"O In the good old days there used to be support for
298 .\"O the European Latin-1
299 .\"O .B """ISO-8859-1"""
300 .\"O locale (e.g., in libc-4.5.21 and libc-4.6.27), and the Russian
302 .\"O (more precisely, "koi-8r") locale (e.g., in libc-4.6.27),
303 .\"O so that having an environment variable \fILC_CTYPE=ISO-8859-1\fP
304 .\"O sufficed to make
306 .\"O return the right answer.
307 .\"O These days non-English speaking Europeans have to work a bit harder,
308 .\"O and must install actual locale files.
309 ¸Å¤¤è¤»þÂå¤Ë¤Ï (Î㤨¤Ð libc-4.5.21 ¤È libc-4.6.27 ¤Ê¤É¤Ç¤Ï)¡¢
310 European Latin-1 ¸þ¤±¤Ë
311 \fB"ISO-8859-1"\fP ¥í¥±¡¼¥ë¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤ª¤ê¡¢
312 ¥í¥·¥¢¸ì (Russian) ¸þ¤±¤Ë \fB"KOI-8"\fP
313 (¤è¤êÀµ³Î¤Ë¤Ï "koi-8r") ¥í¥±¡¼¥ë¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤¿¡£
314 ½¾¤Ã¤Æ´Ä¶ÊÑ¿ô¤ò \fILC_CTYPE=ISO-8859-1\fP ¤È»ØÄꤹ¤ë¤À¤±¤Ç
316 ¤ÏÀµ¤·¤¤Åú¤¨¤òÊÖ¤·¤¿¡£
317 ºÇ¶á¤Ç¤Ï¡¢±Ñ¸ì°Ê³°¤ò»È¤¦¥è¡¼¥í¥Ã¥Ñ¿Í¤Ï¤â¤¦¾¯¡¹¤ä¤Ã¤«¤¤¤Êºî¶È¤òɬÍפȤ·¡¢
318 ¼ÂºÝ¤Î¥í¥±¡¼¥ë¥Õ¥¡¥¤¥ë¤ò¥¤¥ó¥¹¥È¡¼¥ë¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£