名前空間
変種

toupper

提供: cppreference.com
< c | string | byte
<tbody> </tbody>
ヘッダ <ctype.h> で定義
int toupper( int ch );

現在設定されている C のロケールよって定義されている文字変換ルールに従って、指定された文字を大文字に変換します。

デフォルトの "C" ロケールでは、小文字 abcdefghijklmnopqrstuvwxyz が対応する大文字 ABCDEFGHIJKLMNOPQRSTUVWXYZ に変換されます。

引数

ch - 変換する文字。 ch の値が unsigned char で表現できず、 EOF とも等しくない場合、動作は未定義です。

戻り値

ch の大文字バージョン、または現在の C のロケールに大文字のバージョンがない場合は無変更の ch

#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

参考文献

  • C11 standard (ISO/IEC 9899:2011):
  • 7.4.2.2 The toupper function (p: 204)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.4.2.2 The toupper function (p: 185)
  • C89/C90 standard (ISO/IEC 9899:1990):
  • 4.3.2.2 The toupper function

関連項目

文字を小文字に変換します
(関数) [edit]
ワイド文字を大文字に変換します
(関数) [edit]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.