toupper
From cppreference.com
| ヘッダ <ctype.h> で定義 |
||
| int toupper( int ch ); |
||
現在インストールされているCロケールで定義されている文字変換規則に従って、指定された文字を大文字に変換します。
デフォルトの "C" ロケールでは、次の小文字 abcdefghijklmnopqrstuvwxyz は、それぞれ対応する大文字 ABCDEFGHIJKLMNOPQRSTUVWXYZ に置き換えられます。
目次 |
[編集] パラメータ
| 文字 | - | 変換される文字。 ch の値が unsigned char として表現できず、かつ EOF と等しくない場合、動作は未定義です。 |
[編集] 戻り値
ch の大文字バージョン、または現在のCロケールで大文字バージョンがリストされていない場合は、変更されない ch。
[編集] 例
このコードを実行
#include <ctype.h> #include <limits.h> #include <locale.h> #include <stdio.h> int main(void) { // in the default locale: for (unsigned char l = 0, u; l != UCHAR_MAX; ++l) if ((u = toupper(l)) != l) printf("%c%c ", l, u); printf("\n\n"); unsigned char c = '\xb8'; // the character ž in ISO-8859-15 // but ¸ (cedilla) in ISO-8859-1 setlocale(LC_ALL, "en_US.iso88591"); printf("in iso8859-1, toupper('0x%x') gives 0x%x\n", c, toupper(c)); setlocale(LC_ALL, "en_US.iso885915"); printf("in iso8859-15, toupper('0x%x') gives 0x%x\n", c, toupper(c)); }
実行結果の例
aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ
in iso8859-1, toupper('0xb8') gives 0xb8
in iso8859-15, toupper('0xb8') gives 0xb4[編集] 参考文献
- C23標準 (ISO/IEC 9899:2024)
- 7.4.2.2 toupper関数 (p: TBD)
- C17標準 (ISO/IEC 9899:2018)
- 7.4.2.2 toupper関数 (p: 147-148)
- C11標準 (ISO/IEC 9899:2011)
- 7.4.2.2 toupper関数 (p: 204)
- C99標準 (ISO/IEC 9899:1999)
- 7.4.2.2 toupper関数 (p: 185)
- C89/C90標準 (ISO/IEC 9899:1990)
- 4.3.2.2 toupper関数
[編集] 関連項目
| 文字を小文字に変換する (関数) | |
| (C95) |
ワイド文字を大文字に変換する (関数) |
| C++ ドキュメント (toupper)
| |