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>
40 .\"WORD: portable 互換性のある
41 .\"WORD: regular expression 正規表現
42 .\"WORD: range expressions 範囲表現
43 .\"WORD: equivalence classes 等価クラス
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 関数はプログラムのカレントロケールを設定したり
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 正規表現のマッチング (範囲表現と等価クラスのマッチングを決定する)
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.
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
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" などでも良いし
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 の場合、ロケールの各部分の設定には環境変数が参照される。
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 ()
163 次にカテゴリ (category) と同じ名前の環境変数
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
204 .IR language "[_" territory "][." codeset "][@" modifier "]"
210 は ISO 3166 の国名コードである。
216 のような文字集合や文字符号化識別子である。
217 .\"O For a list of all supported locales, try "locale \-a", cf.\&
219 サポートされているロケールの一覧を得るには、
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.
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 プログラムをすべてのロケールに対して互換にしたければ、
259 setlocale(LC_ALL, "");
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.
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 などでは)、
311 \fB"ISO-8859-1"\fP ロケールがサポートされており、
312 ロシア語 (Russian) 向けに \fB"KOI-8"\fP
313 (より正確には "koi-8r") ロケールがサポートされていた。
314 従って環境変数を \fILC_CTYPE=ISO-8859-1\fP と指定するだけで
317 最近では、英語以外を使うヨーロッパ人はもう少々やっかいな作業を必要とし、
318 実際のロケールファイルをインストールしなければならない。