towupper
來自 cppreference.com
在標頭檔案 <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