CppDS.com

C++ 98 11 14 17 20 手册

std::towlower

来自cppreference.com
< cpp‎ | string‎ | wide
定义于头文件 <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 <iostream>
#include <cwctype>
#include <clocale>
 
int main()
{
    wchar_t c = L'\u0190'; // 拉丁文大写字母开 E ('Ɛ')
 
    std::cout << std::hex << std::showbase;
    std::cout << "in the default locale, towlower(" << (std::wint_t)c << ") = "
              << std::towlower(c) << '\n';
    std::setlocale(LC_ALL, "en_US.utf8");
    std::cout << "in Unicode locale, towlower(" << (std::wint_t)c << ") = "
              << std::towlower(c) << '\n';
}

输出:

in the default locale, towlower(0x190) = 0x190
in Unicode locale, towlower(0x190) = 0x25b

参阅

转换宽字符为大写
(函数)
用本地环境的 ctype 刻面将字符转换为小写
(函数模板)
转换字符为小写
(函数)
关闭