toupper
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <ctype.h> で定義
|
||
int toupper( int ch ); |
||
現在設定されている C のロケールよって定義されている文字変換ルールに従って、指定された文字を大文字に変換します。
デフォルトの "C" ロケールでは、小文字 abcdefghijklmnopqrstuvwxyz が対応する大文字 ABCDEFGHIJKLMNOPQRSTUVWXYZ に変換されます。
引数
| ch | - | 変換する文字。 ch の値が unsigned char で表現できず、 EOF とも等しくない場合、動作は未定義です。
|
戻り値
ch の大文字バージョン、または現在の C のロケールに大文字のバージョンがない場合は無変更の ch。
例
Run this code
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include <limits.h>
int main(void)
{
/* In the default locale: */
unsigned char u;
for (unsigned char l=0; l<UCHAR_MAX; l++) {
u = toupper(l);
if (l!=u) printf("%c%c ", l,u);
}
printf("\n\n");
unsigned char c = '\xb8'; // the character Ž in ISO-8859-15
// but ´ (acute accent) in ISO-8859-1
unsigned char c2 = c; // for printing
setlocale(LC_ALL, "en_US.iso88591");
printf("in iso8859-1, toupper('0x%x') gives 0x%x\n", c2, toupper(c));
setlocale(LC_ALL, "en_US.iso885915");
printf("in iso8859-15, toupper('0x%x') gives 0x%x\n", c2, 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