.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de) .\" and Copyright 1999 by Bruno Haible (haible@clisp.cons.org) .\" .\" %%%LICENSE_START(VERBATIM) .\" 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_END .\" .\" 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. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1998 Tanoshima Hidetohsi .\" all rights reserved. .\" Translated May 29 1998, Tanoshima Hidetoshi .\" Modified Mon Oct 2 11:09:18 JST 2000 .\" by HANATAKA Shinya .\" Updated Fri May 4 01:49:48 JST 2001 .\" by Kentaro Shirakata .\" Updated Sat Oct 12 2002 by NAKANO Takeo .\" .TH SETLOCALE 3 2017\-09\-15 GNU "Linux Programmer's Manual" .SH 名前 setlocale \- 現在のロケール (locale) を設定する .SH 書式 .nf \fB#include \fP .PP \fBchar *setlocale(int \fP\fIcategory\fP\fB, const char *\fP\fIlocale\fP\fB);\fP .fi .SH 説明 \fBsetlocale\fP() 関数はプログラムのカレントロケールを設定したり 問い合わせたりするのに用いられる。 .PP \fIlocale\fP が NULL でなければ、プログラムのカレントロケールは引数に従って変更される。 引数 \fIcategory\fP はプログラムのカレントロケールのどの部分を変更するかを決める。 .TS lB lB lB l. カテゴリー 制御対象 LC_ALL 全てのロケール LC_ADDRESS T{ 住所と地理関連の .br 要素のフォーマット (*) T} LC_COLLATE 文字の照合順序 LC_CTYPE 文字の分類 LC_IDENTIFICATION ロケールの説明メタデータ (*) LC_MEASUREMENT T{ 単位系に関する設定 .br (メートル法か US 由来の単位系) (*) T} LC_MESSAGES 地域化可能な自然言語メッセージ LC_MONETARY 金額の表示方法 LC_NAME 人へのあいさつの言葉 LC_NUMERIC 金額以外の数値の表示方法 LC_PAPER 標準の紙のサイズに関する設定 (*) LC_TELEPHONE 電話サービスで使用されるフォーマット (*) LC_TIME 日付と時刻の表示方法 .TE .PP 上の表でアスタリスクが付い ているたカテゴリーは GNU 拡張である。 ロケールのカテゴリーの詳細な情報は \fBlocale\fP(7) を参照。 .PP 引数 \fIlocale\fP は \fIcategory\fP に設定する文字列へのポインターである。 この文字列はよく知られた定数である "C" や "da_DK" などでも良いし (以下を参照)、他のときに \fBsetlocale\fP() を呼び出した際に返された、内部用の文字列でも良い。 .PP \fIlocale\fP が空文字列 \fB""\fP の場合、ロケールの各部分の設定には環境変数が参照される。 その詳細は実装依存である。 glibc の場合、まず最初に (どんな \fIcategory\fP に対しても) 環境変数 \fBLC_ALL\fP が検査される。 次にカテゴリー (category) と同じ名前の環境変数 (上記の表を参照) が検査され、最後に環境変数 \fBLANG\fP が検査される。 最初に見つかった環境変数を使用する。 その値がロケール指定として正しくなければ、ロケールは変更されず、 \fBsetlocale\fP() は NULL を返す。 .PP The locale \fB"C"\fP or \fB"POSIX"\fP is a portable locale; it exists on all conforming systems. .PP A locale name is typically of the form \fIlanguage\fP[_\fIterritory\fP][.\fIcodeset\fP][@\fImodifier\fP], where \fIlanguage\fP is an ISO 639 language code, \fIterritory\fP is an ISO 3166 country code, and \fIcodeset\fP is a character set or encoding identifier like \fBISO\-8859\-1\fP or \fBUTF\-8\fP. For a list of all supported locales, try "locale \-a" (see \fBlocale\fP(1)). .PP \fIlocale\fP が NULL ならば、現在のロケールを問い合わせるのみで変更はしない。 .PP main プログラムの起動時には、 互換性のある \fB"C"\fP ロケールがデフォルトで選択される。 プログラムをすべてのロケールに対して互換にしたければ、 プログラムの初期化の後に .PP .in +4n .EX setlocale(LC_ALL, ""); .EE .in .PP を呼び出し、ロケール依存の情報には \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 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lbw26 l l l. インターフェース 属性 値 T{ \fBsetlocale\fP() T} Thread safety MT\-Unsafe const:locale env .TE .sp 1 .SH 準拠 POSIX.1\-2001, POSIX.1\-2008, C89, C99. .PP The C standards specify only the categories \fBLC_ALL\fP, \fBLC_COLLATE\fP, \fBLC_CTYPE\fP, \fBLC_MONETARY\fP, \fBLC_NUMERIC\fP, and \fBLC_TIME\fP. POSIX.1 adds \fBLC_MESSAGES\fP. The remaining categories are GNU extensions. .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 プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。