Namespaces
Variants

std:: towupper

From cppreference.net
定义于头文件 <cwctype>

将给定的宽字符转换为大写形式(如果可能)。

如果 ch 的值既不能表示为 wchar_t ,也不等于宏 WEOF 的值,则行为是未定义的。

目录

参数

ch - 待转换的宽字符

返回值

ch 的大写版本,若当前 C 区域设置中未列出对应大写形式则返回原值 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

参见

将宽字符转换为小写
(函数)
使用 locale 的 ctype 平面将字符转换为大写
(函数模板)
将字符转换为大写
(函数)
C 文档 for towupper