OSDN Git Service

02c7202330affc798a40ae827fd0d98151f1b9d5
[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)