towupper
来自 cppreference.cn
定义于头文件 <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