Scroll to navigation

TOUPPER(3) Linux Programmer's Manual TOUPPER(3)

名前

toupper, tolower, toupper_l, tolower_l - 小文字を大文字にする。または大文字を小文字にする。

書式

#include <ctype.h>
int toupper(int c);
int tolower(int c);
int toupper_l(int c, locale_t locale);
int tolower_l(int c, locale_t locale);

glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):

toupper_l(), tolower_l():

_XOPEN_SOURCE >= 700
_GNU_SOURCE

説明

これらの関数は、小文字を大文字に、もしくは大文字を小文字に変換する。

c が小文字の場合、現在のロケールで大文字表現が存在する場合、 toupper() は対応する大文字を返す。大文字表現が存在しない場合、c を返す。 toupper_l() 関数は同じ動作をするが、ロケールハンドル locale が参照するロケールを使って変換を行う。

If c is an uppercase letter, tolower() returns its lowercase equivalent, if a lowercase representation exists in the current locale. Otherwise, it returns c. The tolower_l() function performs the same task, but uses the locale referred to by the locale handle locale.

もし cunsigned char 値でも EOF でもない場合、これらの関数の動作は未定義である。

locale が特別なロケールオブジェクト LC_GLOBAL_LOCALE の場合 (duplocale(3) 参照)、または locale が有効なロケールオブジェクトハンドルでない場合、 toupper_l() と tolower_l() の動作は未定義である。

返り値

変換ができれば変換後の文字を返す。できなければ変換前の c を返す。

属性

この節で使用されている用語の説明については、 attributes(7) を参照。

インターフェース 属性
toupper(), tolower(), toupper_l(), tolower_l() Thread safety MT-Safe

準拠

toupper(), tolower(): C89, C99, 4.3BSD, POSIX.1-2001, POSIX.1-2008.

toupper_l(), tolower_l(): POSIX.1-2008.

注意

The standards require that the argument c for these functions is either EOF or a value that is representable in the type unsigned char. If the argument c is of type char, it must be cast to unsigned char, as in the following example:


char c;
...
res = toupper((unsigned char) c);

This is necessary because char may be the equivalent signed char, in which case a byte where the top bit is set would be sign extended when converting to int, yielding a value that is outside the range of unsigned char.

なにが大文字でなにが小文字なのかということの詳細は、ロケールに依存している。たとえば、デフォルトの "C" ロケールではウムラウトを認識しないため、それらの文字は変換できない。

いくつかの非英語ロケールでは、対応する大文字を持たない小文字が存在する。 ドイツ語のエスツェットが一つの例である。

関連項目

isalpha(3), newlocale(3), setlocale(3), towlower(3), towupper(3), uselocale(3), locale(7)

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

2017-09-15 GNU