非常教程

C参考手册

字符串 | Strings

towupper

在头文件<wctype.h>中定义

win_t towupper(wint_t wc);

(自C95以来)

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

参数

wc

-

宽字符被转换

返回值

如果在当前C语言环境中wcwc列出大写版本,则为大写版本或未修改。

注意

该函数只能执行1:1的字符映射,例如,'ß'的大写形式是(有些例外)双字符字符串“SS”,这是无法通过该函数获得的towupper

示例

#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函数(p: 453)
  • C99标准(ISO/IEC 9899:1999):
    • 7.25.3.1.2 towupper函数(p: 399)

See also

towlower (C95)

converts a wide character to lowercase (function)

toupper

converts a character to uppercase (function)

| C++ documentation for towupper |

 © cppreference.com

Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.

http://en.cppreference.com/w/c/string/wide/towupper

C

C 语言是一门通用计算机编程语言,应用广泛。C 语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。