2 .\" Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .\"*******************************************************************
28 .\" This file was generated with po4a. Translate the source file.
30 .\"*******************************************************************
31 .TH DUPLOCALE 3 2014\-03\-12 Linux "Linux Programmer's Manual"
33 duplocale \- ロケールオブジェクトを複製する
36 \fB#include <locale.h>\fP
38 \fBlocale_t duplocale(locale_t \fP\fIlocobj\fP\fB);\fP
42 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照):
50 _XOPEN_SOURCE\ >=\ 700
57 \fBduplocale\fP() 関数は \fIlocobj\fP が参照するロケールオブジェクトの複製を作成する。
59 \fIlocobj\fP が \fBLC_GLOBAL_LOCALE\fP の場合、 \fBduplocale\fP() は \fBsetlocale\fP(3)
60 により判定されたグローバルロケールのコピーを含むロケールオブジェクトを作成する。
62 成功すると、 \fBduplocale\fP() は新しいロケールオブジェクトのハンドルを返す。 エラーの場合、 \fI(locale_t)\ 0\fP を返し、
63 \fIerrno\fP にエラーの原因を示す値を設定する。
67 ロケールオブジェクトの複製を作成するのに十分なメモリがない。
69 \fBduplocale\fP() 関数は GNU C ライブラリのバージョン 2.3 で初めて登場した。
73 Duplicating a locale can serve the following purposes:
75 To create a copy of a locale object in which one of more categories are to
76 be modified (using \fBnewlocale\fP(3)).
78 To obtain a handle for the current locale which can used in other functions
79 that employ a locale handle, such as \fBtoupper_l\fP(3). This is done by
80 applying \fBduplocale\fP() to the value returned by the following call:
82 loc = uselocale((locale_t) 0);
85 This technique is necessary, because the above \fBuselocale\fP(3) call may
86 return the value \fBLC_GLOBAL_LOCALE\fP, which results in undefined behavior if
87 passed to functions such as \fBtoupper_l\fP(3). Calling \fBduplocale\fP() can be
88 used to ensure that the \fBLC_GLOBAL_LOCALE\fP value is converted into a usable
89 locale object. See EXAMPLE, below.
91 \fBduplocale\fP() で作成された各ロケールオブジェクトは \fBfreelocale\fP(3) を使って解放すべきである。
93 以下のプログラムでは、 \fBtoupper_l\fP(3) に渡す現在のロケールのハンドルを取得するのに \fBuselocale\fP(3) と
94 \fBduplocale\fP() を使用する。
95 このプログラムはコマンドライン引き数として文字列を一つ取る。この文字列は、大文字に変換され、標準出力に表示される。 以下は使用例である。
105 #define _XOPEN_SOURCE 700
111 #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \e
115 main(int argc, char *argv[])
121 fprintf(stderr, "Usage: %s string\en", argv[0]);
125 /* この一連の処理は必要である。 uselocale() は toupper_l() の
126 引き数として渡すことができない値 LC_GLOBAL_LOCALE を返す
129 loc = uselocale((locale_t) 0);
130 if (loc == (locale_t) 0)
131 errExit("uselocale");
133 nloc = duplocale(loc);
134 if (nloc == (locale_t) 0)
135 errExit("duplocale");
137 for (p = argv[1]; *p; p++)
138 putchar(toupper_l(*p, nloc));
148 \fBfreelocale\fP(3), \fBnewlocale\fP(3), \fBsetlocale\fP(3), \fBuselocale\fP(3),
149 \fBlocale\fP(5), \fBlocale\fP(7)
151 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部
152 である。プロジェクトの説明とバグ報告に関する情報は
153 http://www.kernel.org/doc/man\-pages/ に書かれている。