TOUPPER

Section: Linux Programmer's Manual (3)
Updated: 2017-09-15
Index JM Home Page
 

名前

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():

glibc 2.10 以降:
_XOPEN_SOURCE >= 700
glibc 2.10 より前:
_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.

もし c が unsigned 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/ に書かれている。

関連キーワード

大文字   ロケール   小文字   toupper   locale   tolower   表現   ハンドル   lowercase   equivalent   未定義   argument   type   ctype   検査   マクロ   要件   macros   uppercase   letter   representation   exists   current   Otherwise   performs

Linux マニュアル 一覧

関連するコマンド・関数

tolower.3   tolower_l.3   toupper_l.3   towupper.3   towupper_l.3   towlower.3
 

Index

名前
書式
説明
返り値
属性
準拠
注意
関連項目
この文書について

This document was created by man2html, using the manual pages.
Time: 04:39:37 GMT, October 11, 2026