Namespaces
Variants

towupper

From cppreference.net
< c ‎ | string ‎ | wide
定义于头文件 <wctype.h>
wint_t towupper ( wint_t wc ) ;
(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++ 文档 关于 towupper