命名空间
变体
操作

towupper

来自 cppreference.cn
< c‎ | string‎ | wide
定义于头文件 <wctype.h>
wint_t towupper( wint_t wc );
(since C95)

如果可能,将给定的宽字符转换为大写。

目录

[编辑] 参数

wc - 要转换的宽字符

[编辑] 返回值

wc 的大写版本,如果当前 C 语言环境未列出大写版本,则返回未修改的 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

[编辑] 参考文献

  • C11 标准 (ISO/IEC 9899:2011)
  • 7.30.3.1.2 towupper 函数 (页码:453)
  • C99 标准 (ISO/IEC 9899:1999)
  • 7.25.3.1.2 towupper 函数 (页码:399)

[编辑] 参见

将宽字符转换为小写
(函数) [编辑]
将字符转换为大写
(函数) [编辑]
C++ 文档 for towupper