toupper, _toupper, towupper, _toupper_l, _towupper_l

将字符转换为大写。

语法

int toupper(
   int c
);
int _toupper(
   int c
);
int towupper(
   wint_t c
);
int _toupper_l(
   int c ,
   _locale_t locale
);
int _towupper_l(
   wint_t c ,
   _locale_t locale
);

参数

c
要转换的字符。

locale
要使用的区域设置。

返回值

如果可行,则其中的各个例程将转换 c 的副本,并返回结果。

如果 ciswlower 为非零值的宽字符并且有 iswupper 为非零值的对应宽字符,则 towupper 返回对应的宽字符;否则,towupper 返回未改变的 c

没有保留返回值来指示错误。

注解

如果可行且恰当,则其中的各个例程将指定小写字母转换为大写字母。 towupper 的大小写转换是特定于区域设置的。 只改变与当前区域设置相关的字符的大小写。 没有 _l 后缀的函数使用当前设置的区域设置。 这些带有 _l 后缀的函数的版本将区域设置用作参数并使用它,而不是使用当前设置的区域设置。 有关详细信息,请参阅 Locale

要使 toupper 提供预期结果,__isascii 必须返回非零值。

默认情况下,此函数的全局状态范围限定为应用程序。 若要更改此行为,请参阅 CRT 中的全局状态

一般文本例程映射

TCHAR.H 例程 _UNICODE_MBCS 未定义 _MBCS 已定义 _UNICODE 已定义
_totupper toupper _mbctoupper towupper
_totupper_l _toupper_l _mbctoupper_l _towupper_l

注意

_toupper_l_towupper_l 没有区域设置相关性,并且不应直接调用。 它们供 _totupper_l 内部使用。

要求

例程 必需的标头
toupper <ctype.h>
_toupper <ctype.h>
towupper <ctype.h> 或 <wchar.h>

有关兼容性的详细信息,请参阅 兼容性

示例

请参阅 to 函数中的示例。

另请参阅

is, isw 例程
to 函数
区域设置
多字节字符序列的解释