std::towupper
來自 cppreference.com
定義於標頭檔案 <cwctype> |
||
std::wint_t towupper( std::wint_t ch ); |
||
如果可能,將給定的寬字元轉換為大寫。
如果 ch 的值既不能表示為 wchar_t,也不等於宏 WEOF 的值,則行為未定義。
目錄 |
[編輯] 引數
ch | - | 要轉換的寬字元 |
[編輯] 返回值
如果當前 C 語言環境中沒有 ch 的大寫版本,則返回 ch 的大寫版本或未修改的 ch。
[編輯] 注意
此函式只能執行 1:1 字元對映,例如,'ß' 的大寫形式(除了一些例外)是雙字元字串 "SS",這不能透過 std::towupper
獲得。
ISO 30112 指定了 Unicode 字元對中哪些包含在此對映中。
[編輯] 示例
拉丁字母 'ſ' (U+017F) 是 'S' (U+0053) 的替代小寫形式。
執行此程式碼
#include <clocale> #include <cwctype> #include <iostream> int main() { wchar_t c = L'\u017f'; // Latin small letter Long S ('ſ') std::cout << std::hex << std::showbase; std::cout << "in the default locale, towupper(" << static_cast<std::wint_t>(c) << ") = " << std::towupper(c) << '\n'; std::setlocale(LC_ALL, "en_US.utf8"); std::cout << "in Unicode locale, towupper(" << static_cast<std::wint_t>(c) << ") = " << std::towupper(c) << '\n'; }
輸出
in the default locale, towupper(0x17f) = 0x17f in Unicode locale, towupper(0x17f) = 0x53
[編輯] 參閱
將寬字元轉換為小寫 (函式) | |
使用區域設定的 ctype 刻面將字元轉換為大寫 (函式模板) | |
將字元轉換為大寫 (函式) | |
C 文件 對應 towupper
|