OSDN Git Service

0e616d4f23ceb97a8f2442f26000e7643e653d92
[linuxjm/LDP_man-pages.git] / draft / man3 / setlocale.3
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\" and Copyright 1999 by Bruno Haible (haible@clisp.cons.org)
3 .\"
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.
7 .\"
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.
12 .\"
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
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" License.
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)
29 .\"
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>
38 .\"
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           ÆâÉôʸ»úÎó
48 .\"
49 .TH SETLOCALE 3  2008-12-05 "GNU" "Linux Programmer's Manual"
50 .SH Ì¾Á°
51 .\"O setlocale \- set the current locale
52 setlocale \- ¸½ºß¤Î¥í¥±¡¼¥ë (locale) ¤òÀßÄꤹ¤ë
53 .SH ½ñ¼°
54 .nf
55 .B #include <locale.h>
56 .sp
57 .BI "char *setlocale(int " category ", const char *" locale );
58 .fi
59 .SH ÀâÌÀ
60 .\"O .BR setlocale ()
61 .\"O function is used to set or query the program's current locale.
62 .BR setlocale ()
63 ´Ø¿ô¤Ï¥×¥í¥°¥é¥à¤Î¥«¥ì¥ó¥È¥í¥±¡¼¥ë¤òÀßÄꤷ¤¿¤ê
64 Ì䤤¹ç¤ï¤»¤¿¤ê¤¹¤ë¤Î¤ËÍѤ¤¤é¤ì¤ë¡£
65 .PP
66 .\"O If
67 .\"O .I locale
68 .\"O is not NULL,
69 .\"O the program's current locale is modified according to the arguments.
70 .I locale
71 ¤¬ NULL ¤Ç¤Ê¤±¤ì¤Ð¡¢¥×¥í¥°¥é¥à¤Î¥«¥ì¥ó¥È¥í¥±¡¼¥ë¤Ï°ú¤­¿ô¤Ë½¾¤Ã¤ÆÊѹ¹¤µ¤ì¤ë¡£
72 .\"O The argument
73 .\"O .I category
74 .\"O determines which parts of the program's current locale should be modified.
75 °ú¤­¿ô
76 .I category
77 ¤Ï¥×¥í¥°¥é¥à¤Î¥«¥ì¥ó¥È¥í¥±¡¼¥ë¤Î¤É¤ÎÉôʬ¤òÊѹ¹¤¹¤ë¤«¤ò·è¤á¤ë¡£
78 .TP
79 .B LC_ALL
80 .\"O for all of the locale.
81 Á´¤Æ¤Î¥í¥±¡¼¥ë
82 .TP
83 .B LC_COLLATE
84 .\"O for regular expression matching (it determines the meaning
85 .\"O of range expressions and equivalence classes) and string collation.
86 Àµµ¬É½¸½¤Î¥Þ¥Ã¥Á¥ó¥° (ÈÏ°Ïɽ¸½¤ÈÅù²Á¥¯¥é¥¹¤Î¥Þ¥Ã¥Á¥ó¥°¤ò·èÄꤹ¤ë)
87 ¤Èʸ»úÎó¤Î¾È¹ç (collation)
88 .TP
89 .B LC_CTYPE
90 .\"O for regular expression matching, character classification, conversion,
91 .\"O case-sensitive comparison, and wide character functions.
92 Àµµ¬É½¸½¤Î¥Þ¥Ã¥Á¥ó¥°¡¢Ê¸»ú¤ÎʬÎࡢʸ»ú¤ÎÊÑ´¹¡¢Âçʸ»ú¾®Ê¸»úÈæ³Ó¡¢
93 ¥ï¥¤¥Éʸ»ú´Ø¿ô
94 .TP
95 .B LC_MESSAGES
96 .\"O for localizable natural-language messages.
97 ÃÏ°è²½²Äǽ¤Ê¼«Á³¸À¸ì¥á¥Ã¥»¡¼¥¸
98 .TP
99 .B LC_MONETARY
100 .\"O for monetary formatting.
101 Ä̲ߤνñ¼°
102 .TP
103 .B LC_NUMERIC
104 .\"O for number formatting (such as the decimal point and the thousands separator).
105 ¿ôÃͤνñ¼° (¾®¿ôÅÀ¤ä 3 ·å¤´¤È¤Î¶èÀÚ¤ê)
106 .TP
107 .B LC_TIME
108 .\"O for time and date formatting.
109 »þ¹ï¤ÈÆüÉÕ¤±¤Î½ñ¼°
110 .PP
111 .\"O The argument
112 .\"O .I locale
113 .\"O is a pointer to a character string containing the
114 .\"O required setting of
115 .\"O .IR category .
116 °ú¤­¿ô
117 .I locale
118 ¤Ï
119 .I category
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 (°Ê²¼¤ò»²¾È)¡¢Â¾¤Î¤È¤­¤Ë
126 .BR setlocale ()
127 ¤ò¸Æ¤Ó½Ð¤·¤¿ºÝ¤ËÊÖ¤µ¤ì¤¿¡¢ÆâÉôÍѤÎʸ»úÎó¤Ç¤âÎɤ¤¡£
128 .PP
129 .\"O If
130 .\"O .I locale
131 .\"O is
132 .\"O .BR """""" ,
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.
136 .I locale
137 ¤¬ \fB""\fP ¤Î¾ì¹ç¡¢¥í¥±¡¼¥ë¤Î³ÆÉôʬ¤ÎÀßÄê¤Ë¤Ï´Ä¶­ÊÑ¿ô¤¬»²¾È¤µ¤ì¤ë¡£
138 ¤½¤Î¾ÜºÙ¤Ï¼ÂÁõ°Í¸¤Ç¤¢¤ë¡£
139 .\"O For glibc, first (regardless of
140 .\"O .IR category ),
141 .\"O the environment variable
142 .\"O .B LC_ALL
143 .\"O is inspected,
144 .\"O next the environment variable with the same name as the category
145 .\"O .RB ( LC_COLLATE ,
146 .\"O .BR LC_CTYPE ,
147 .\"O .BR LC_MESSAGES ,
148 .\"O .BR LC_MONETARY ,
149 .\"O .BR LC_NUMERIC ,
150 .\"O .BR LC_TIME )
151 .\"O and finally the environment variable
152 .\"O .BR LANG .
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 ()
157 .\"O returns NULL.
158 glibc ¤Î¾ì¹ç¡¢¤Þ¤ººÇ½é¤Ë (¤É¤ó¤Ê
159 .I category
160 ¤ËÂФ·¤Æ¤â) ´Ä¶­ÊÑ¿ô
161 .B LC_ALL
162 ¤¬¸¡ºº¤µ¤ì¤ë¡£
163 ¼¡¤Ë¥«¥Æ¥´¥ê (category) ¤ÈƱ¤¸Ì¾Á°¤Î´Ä¶­ÊÑ¿ô
164 .RB ( LC_COLLATE ,
165 .BR LC_CTYPE ,
166 .BR LC_MESSAGES ,
167 .BR LC_MONETARY ,
168 .BR LC_NUMERIC ,
169 .BR LC_TIME )
170 ¤¬¸¡ºº¤µ¤ì¡¢ºÇ¸å¤Ë´Ä¶­ÊÑ¿ô
171 .B LANG
172 ¤¬¸¡ºº¤µ¤ì¤ë¡£
173 ºÇ½é¤Ë¸«¤Ä¤«¤Ã¤¿´Ä¶­ÊÑ¿ô¤ò»ÈÍѤ¹¤ë¡£
174 ¤½¤ÎÃͤ¬¥í¥±¡¼¥ë»ØÄê¤È¤·¤ÆÀµ¤·¤¯¤Ê¤±¤ì¤Ð¡¢¥í¥±¡¼¥ë¤ÏÊѹ¹¤µ¤ì¤º¡¢
175 .BR setlocale ()
176 ¤Ï NULL ¤òÊÖ¤¹¡£
177 .PP
178 .\"O The locale
179 .\"O .B """C"""
180 .\"O or
181 .\"O .B """POSIX"""
182 .\"O is a portable locale; its
183 .\"O .B LC_CTYPE
184 .\"O part corresponds to the 7-bit ASCII
185 .\"O character set.
186 \fB"C"\fP ¥í¥±¡¼¥ë¤ä \fB"POSIX"\fP ¥í¥±¡¼¥ë¤Ï¸ß´¹À­¤Î¤¢¤ë¥í¥±¡¼¥ë¤Ç¤¢¤ë¡£
187 ¤³¤Î
188 .B LC_CTYPE
189 ¤ÎÉôʬ¤Ï 7 ¥Ó¥Ã¥È ASCII Ê¸»ú½¸¹ç¤ËÁêÅö¤·¤Æ¤¤¤ë¡£
190 .PP
191 .\"O A locale name is typically of the form
192 .\"O .IR language "[_" territory "][." codeset "][@" modifier "],"
193 .\"O where
194 .\"O .I language
195 .\"O is an ISO 639 language code,
196 .\"O .I territory
197 .\"O is an ISO 3166 country code, and
198 .\"O .I codeset
199 .\"O is a character set or encoding identifier like
200 .\"O .B "ISO-8859-1"
201 .\"O or
202 .\"O .BR "UTF-8" .
203 ¥í¥±¡¼¥ë̾¤Î½ñ¼°¤Ï¡¢Ä̾ï
204 .IR language "[_" territory "][." codeset "][@" modifier "]"
205 ¤È¤¤¤¦¤â¤Î¤Ç¤¢¤ë¡£
206 ¤³¤³¤Ç
207 .I language
208 ¤Ï ISO 639 ¤Î¸À¸ì¥³¡¼¥É¤Ç¤¢¤ë¡£
209 .I territory
210 ¤Ï ISO 3166 ¤Î¹ñ̾¥³¡¼¥É¤Ç¤¢¤ë¡£
211 .I codeset
212 ¤Ï
213 .B "ISO-8859-1"
214 ¤ä
215 .B "UTF-8"
216 ¤Î¤è¤¦¤Êʸ»ú½¸¹ç¤äʸ»úÉä¹æ²½¼±Ê̻ҤǤ¢¤ë¡£
217 .\"O For a list of all supported locales, try "locale \-a", cf.\&
218 .\"O .BR locale (1).
219 ¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¥í¥±¡¼¥ë¤Î°ìÍ÷¤òÆÀ¤ë¤Ë¤Ï¡¢
220 "locale \-a" ¤ò¼Â¹Ô¤·¤Æ¤ß¤è
221 .RB ( locale (1)
222 »²¾È¤Î¤³¤È)¡£
223 .PP
224 .\"O If
225 .\"O .I locale
226 .\"O is NULL, the current locale is only queried, not modified.
227 .I locale
228 ¤¬ NULL ¤Ê¤é¤Ð¡¢¸½ºß¤Î¥í¥±¡¼¥ë¤òÌ䤤¹ç¤ï¤»¤ë¤Î¤ß¤ÇÊѹ¹¤Ï¤·¤Ê¤¤¡£
229 .PP
230 .\"O On startup of the main program, the portable
231 .\"O .B """C"""
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:
236 .\"O .nf
237 .\"O 
238 .\"O     setlocale(LC_ALL, "");
239 .\"O 
240 .\"O .fi
241 .\"O after program initialization, by using the values returned
242 .\"O from a
243 .\"O .BR localeconv (3)
244 .\"O call
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" ,
248 .\"O and by using
249 .\"O .BR strcoll (3),
250 .\"O .BR wcscoll (3)
251 .\"O or
252 .\"O .BR strxfrm (3),
253 .\"O .BR wcsxfrm (3)
254 .\"O to compare strings.
255 ¥×¥í¥°¥é¥à¤ò¤¹¤Ù¤Æ¤Î¥í¥±¡¼¥ë¤ËÂФ·¤Æ¸ß´¹¤Ë¤·¤¿¤±¤ì¤Ð¡¢
256 ¥×¥í¥°¥é¥à¤Î½é´ü²½¤Î¸å¤Ë
257 .nf
258
259     setlocale(LC_ALL, "");
260
261 .fi
262 ¤ò¸Æ¤Ó½Ð¤·¡¢¥í¥±¡¼¥ë°Í¸¤Î¾ðÊó¤Ë¤Ï
263 .BR localeconv (3)
264 ¤ÎÊÖ¤êÃͤòÍѤ¤¡¢
265 .BR "MB_CUR_MAX > 1"
266 ¤Î¾ì¹ç¤Ë¤Ïʸ»úÎó¤ÎÁàºî¤Ë¤Ï¿¥Ð¥¤¥Èʸ»ú¡¢¥ï¥¤¥Éʸ»ú´Ø¿ô¤ò»ÈÍѤ·¡¢
267 ʸ»úÎó¤ÎÈæ³Ó¤Ë¤Ï
268 .BR strcoll (3),
269 .BR wcscoll (3)
270 ¤ä
271 .BR strxfrm (3),
272 .BR wcsxfrm (3)
273 ¤òÍѤ¤¤ë¡£
274 .SH ÊÖ¤êÃÍ
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
281 .\"O locale.
282 .\"O The return value is NULL if the request cannot be honored.
283 .BR setlocale ()
284 ¤Î¸Æ¤Ó½Ð¤·¤ËÀ®¸ù¤¹¤ë¤È¡¢
285 ¤½¤Î¥í¥±¡¼¥ë½¸¹ç¤ËÂбþ¤¹¤ëÆâÉôʸ»úÎó (opaque string) ¤òÊÖ¤¹¡£
286 ¤³¤Îʸ»úÎó¤ÏÀÅŪ¤Êµ­²±°è¤Ë³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
287 ¤³¤ÎÊ֤äÆÍ褿ʸ»úÎó¤ò¡¢¥«¥Æ¥´¥ê»ØÄê¤È¶¦¤Ë¡¢
288 ¤Î¤Á¤Î setlocale ¤Î¸Æ¤Ó½Ð¤·¤Ë»ØÄꤹ¤ì¤Ð¡¢
289 ¥×¥í¥»¥¹¤Î¤½¤ÎÉôʬ¤Î¥í¥±¡¼¥ë¤¬Éü¸µ¤µ¤ì¤ë¡£
290 ÀßÄê¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¤Ë¤Ï¡¢ÊÖ¤êÃͤϠNULL ¤Ë¤Ê¤ë¡£
291 .SH ½àµò
292 C89, C99, POSIX.1-2001.
293 .SH Ãí°Õ
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
301 .\"O .B """KOI-8"""
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
305 .\"O .BR isprint (3)
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 ¤È»ØÄꤹ¤ë¤À¤±¤Ç
315 .BR isprint (3)
316 ¤ÏÀµ¤·¤¤Åú¤¨¤òÊÖ¤·¤¿¡£
317 ºÇ¶á¤Ç¤Ï¡¢±Ñ¸ì°Ê³°¤ò»È¤¦¥è¡¼¥í¥Ã¥Ñ¿Í¤Ï¤â¤¦¾¯¡¹¤ä¤Ã¤«¤¤¤Êºî¶È¤òɬÍפȤ·¡¢
318 ¼ÂºÝ¤Î¥í¥±¡¼¥ë¥Õ¥¡¥¤¥ë¤ò¥¤¥ó¥¹¥È¡¼¥ë¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
319 .SH ´ØÏ¢¹àÌÜ
320 .BR locale (1),
321 .BR localedef (1),
322 .BR isalpha (3),
323 .BR localeconv (3),
324 .BR nl_langinfo (3),
325 .BR rpmatch (3),
326 .BR strcoll (3),
327 .BR strftime (3),
328 .BR charsets (7),
329 .BR locale (7)