.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de) .\" and Copyright 1999 by Bruno Haible (haible@clisp.cons.org) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" License. .\" Modified Sat Jul 24 18:20:12 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Tue Jul 15 16:49:10 1997 by Andries Brouwer (aeb@cwi.nl) .\" Modified Sun Jul 4 14:52:16 1999 by Bruno Haible (haible@clisp.cons.org) .\" Modified Tue Aug 24 17:11:01 1999 by Andries Brouwer (aeb@cwi.nl) .\" Modified Tue Feb 6 03:31:55 2001 by Andries Brouwer (aeb@cwi.nl) .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH SETLOCALE 3 2008\-12\-05 GNU "Linux Programmer's Manual" .SH 名前 setlocale \- 現在のロケール (locale) を設定する .SH 書式 .nf \fB#include \fP .sp \fBchar *setlocale(int \fP\fIcategory\fP\fB, const char *\fP\fIlocale\fP\fB);\fP .fi .SH 説明 \fBsetlocale\fP() 関数はプログラムのカレントロケールを設定したり 問い合わせたりするのに用いられる。 .PP \fIlocale\fP が NULL でなければ、プログラムのカレントロケールは引き数に従って変更される。 引き数 \fIcategory\fP はプログラムのカレントロケールのどの部分を変更するかを決める。 .TP \fBLC_ALL\fP 全てのロケール .TP \fBLC_COLLATE\fP 正規表現のマッチング (範囲表現と等価クラスのマッチングを決定する) と文字列の照合 (collation) .TP \fBLC_CTYPE\fP 正規表現のマッチング、文字の分類、文字の変換、大文字小文字比較、 ワイド文字関数 .TP \fBLC_MESSAGES\fP 地域化可能な自然言語メッセージ .TP \fBLC_MONETARY\fP 通貨の書式 .TP \fBLC_NUMERIC\fP 数値の書式 (小数点や 3 桁ごとの区切り) .TP \fBLC_TIME\fP 時刻と日付けの書式 .PP 引き数 \fIlocale\fP は \fIcategory\fP に設定する文字列へのポインタである。 この文字列はよく知られた定数である "C" や "da_DK" などでも良いし (以下を参照)、他のときに \fBsetlocale\fP() を呼び出した際に返された、内部用の文字列でも良い。 .PP \fIlocale\fP が \fB""\fP の場合、ロケールの各部分の設定には環境変数が参照される。 その詳細は実装依存である。 glibc の場合、まず最初に (どんな \fIcategory\fP に対しても) 環境変数 \fBLC_ALL\fP が検査される。 次にカテゴリ (category) と同じ名前の環境変数 (\fBLC_COLLATE\fP, \fBLC_CTYPE\fP, \fBLC_MESSAGES\fP, \fBLC_MONETARY\fP, \fBLC_NUMERIC\fP, \fBLC_TIME\fP) が検査され、最後に環境変数 \fBLANG\fP が検査される。 最初に見つかった環境変数を使用する。 その値がロケール指定として正しくなければ、ロケールは変更されず、 \fBsetlocale\fP() は NULL を返す。 .PP \fB"C"\fP ロケールや \fB"POSIX"\fP ロケールは互換性のあるロケールである。 この \fBLC_CTYPE\fP の部分は 7 ビット ASCII 文字集合に相当している。 .PP ロケール名の書式は、通常 \fIlanguage\fP[_\fIterritory\fP][.\fIcodeset\fP][@\fImodifier\fP] というものである。 ここで \fIlanguage\fP は ISO 639 の言語コードである。 \fIterritory\fP は ISO 3166 の国名コードである。 \fIcodeset\fP は \fBISO\-8859\-1\fP や \fBUTF\-8\fP のような文字集合や文字符号化識別子である。 サポートされているロケールの一覧を得るには、 "locale \-a" を実行してみよ (\fBlocale\fP(1) 参照のこと)。 .PP \fIlocale\fP が NULL ならば、現在のロケールを問い合わせるのみで変更はしない。 .PP main プログラムの起動時には、 互換性のある \fB"C"\fP ロケールがデフォルトで選択される。 プログラムをすべてのロケールに対して互換にしたければ、 プログラムの初期化の後に .nf setlocale(LC_ALL, ""); .fi を呼び出し、ロケール依存の情報には \fBlocaleconv\fP(3) の返り値を用い、 \fBMB_CUR_MAX > 1\fP の場合には文字列の操作には多バイト文字、ワイド文字関数を使用し、 文字列の比較には \fBstrcoll\fP(3), \fBwcscoll\fP(3) や \fBstrxfrm\fP(3), \fBwcsxfrm\fP(3) を用いる。 .SH 返り値 \fBsetlocale\fP() の呼び出しに成功すると、 そのロケール集合に対応する内部文字列 (opaque string) を返す。 この文字列は静的な記憶域に割り当てられているかもしれない。 この返って来た文字列を、カテゴリ指定と共に、 のちの setlocale の呼び出しに指定すれば、 プロセスのその部分のロケールが復元される。 設定に失敗した場合には、返り値は NULL になる。 .SH 準拠 C89, C99, POSIX.1\-2001. .SH 注意 Linux (というか glibc) は互換性のあるロケールとして \fB"C"\fP と \fB"POSIX"\fP をサポートしている。 古きよき時代には (例えば libc\-4.5.21 と libc\-4.6.27 などでは)、 European Latin\-1 向けに \fB"ISO\-8859\-1"\fP ロケールがサポートされており、 ロシア語 (Russian) 向けに \fB"KOI\-8"\fP (より正確には "koi\-8r") ロケールがサポートされていた。 従って環境変数を \fILC_CTYPE=ISO\-8859\-1\fP と指定するだけで \fBisprint\fP(3) は正しい答えを返した。 最近では、英語以外を使うヨーロッパ人はもう少々やっかいな作業を必要とし、 実際のロケールファイルをインストールしなければならない。 .SH 関連項目 \fBlocale\fP(1), \fBlocaledef\fP(1), \fBisalpha\fP(3), \fBlocaleconv\fP(3), \fBnl_langinfo\fP(3), \fBrpmatch\fP(3), \fBstrcoll\fP(3), \fBstrftime\fP(3), \fBcharsets\fP(7), \fBlocale\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.41 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。