首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::toupper

Defined in header <cctype>

int toupper( int ch );

根据当前安装的C语言环境定义的字符转换规则,将给定字符转换为大写字符。

在默认的“C”区域设置中,以下小写字母abcdefghijklmnopqrstuvwxyz被相应的大写字母替换。ABCDEFGHIJKLMNOPQRSTUVWXYZ...

参数

ch

-

character to be converted. If the value of ch is not representable as unsigned char and does not equal EOF, the behavior is undefined.

返回值

转换字符或ch如果当前C语言环境没有定义大写版本。

二次

代码语言:javascript
复制
#include <iostream>
#include <cctype>
#include <clocale>
 
int main()
{
    unsigned char c = '\xb8'; // the character ž in ISO-8859-15
                              // but ¸ (cedilla) in ISO-8859-1 
 
    std::setlocale(LC_ALL, "en_US.iso88591");
    std::cout << std::hex << std::showbase;
    std::cout << "in iso8859-1, toupper('0xb8') gives " << std::toupper(c) << '\n';
    std::setlocale(LC_ALL, "en_US.iso885915");
    std::cout << "in iso8859-15, toupper('0xb8') gives " << std::toupper(c) << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
in iso8859-1, toupper('0xb8') gives 0xb8
in iso8859-15, toupper('0xb8') gives 0xb4

二次

另见

tolower

converts a character to lowercase (function)

toupper(std::locale)

converts a character to uppercase using the ctype facet of a locale (function template)

towupper

converts a wide character to uppercase (function)

C文件

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券