std::towlower
來自 cppreference.com
定義於標頭檔案 <cwctype> |
||
std::wint_t towlower( std::wint_t ch ); |
||
將給定的寬字元轉換為小寫(如果可能)。
如果 ch 的值既不能表示為 wchar_t 也與宏 WEOF 的值不相等,則行為未定義。
目錄 |
[編輯] 引數
ch | - | 要轉換的寬字元 |
[編輯] 返回值
ch 的小寫版本;如果當前 C 區域設定中沒有列出小寫版本,則為未修改的 ch。
[編輯] 注意
此函式只能執行 1:1 字元對映,例如希臘語大寫字母 'Σ' 有兩種小寫形式,具體取決於其在單詞中的位置:'σ' 和 'ς'。在這種情況下,不能使用 std::towlower
來獲取正確的小寫形式。
ISO 30112 指定了此對映中包含的 Unicode 字元對。
[編輯] 示例
執行此程式碼
#include <clocale> #include <cwctype> #include <iostream> int main() { wchar_t c = L'\u0190'; // Latin capital open E ('Ɛ') std::cout << std::hex << std::showbase; std::cout << "in the default locale, towlower(" << static_cast<std::wint_t>(c) << ") = " << std::towlower(c) << '\n'; std::setlocale(LC_ALL, "en_US.utf8"); std::cout << "in Unicode locale, towlower(" << static_cast<std::wint_t>(c) << ") = " << std::towlower(c) << '\n'; }
輸出
in the default locale, towlower(0x190) = 0x190 in Unicode locale, towlower(0x190) = 0x25b
[編輯] 參閱
將寬字元轉換為大寫 (函式) | |
使用區域設定的 ctype 刻面將字元轉換為小寫(函式模板) | |
將字元轉換為小寫 (函式) | |
C 文件,關於 towlower
|