名稱空間
變體
操作

towupper

來自 cppreference.com
< c‎ | string‎ | wide
在標頭檔案 <wctype.h> 中定義
wint_t towupper( wint_t wc );
(自 C95 起)

如果可能,將給定的寬字元轉換為大寫。

目錄

[編輯] 引數

wc - 要轉換的寬字元

[編輯] 返回值

如果當前 C 語言環境中沒有列出 wc 的大寫版本,則返回 wc 的大寫版本或未修改的 wc

[編輯] 注意

此函式只能執行 1:1 字元對映,例如,“ß”的大寫形式(除少數例外)是雙字元字串“SS”,這無法透過 towupper 獲得。

ISO 30112 指定了此對映中包含哪些 Unicode 字元對。

[編輯] 示例

#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
#include <locale.h>
 
int main(void)
{
    wchar_t wc =  L'\u017f'; // Latin small letter Long S ('ſ')
    printf("in the default locale, towupper(%#x) = %#x\n", wc, towupper(wc));
    setlocale(LC_ALL, "en_US.utf8");
    printf("in Unicode locale, towupper(%#x) = %#x\n", wc, towupper(wc));
}

輸出

in the default locale, towupper(0x17f) = 0x17f
in Unicode locale, towupper(0x17f) = 0x53

[編輯] 參考

  • C11 標準 (ISO/IEC 9899:2011)
  • 7.30.3.1.2 towupper 函式 (p: 453)
  • C99 標準 (ISO/IEC 9899:1999)
  • 7.25.3.1.2 towupper 函式 (p: 399)

[編輯] 另請參閱

將寬字元轉換為小寫
(函式) [編輯]
將字元轉換為大寫
(函式) [編輯]
C++ 文件 中的 towupper