Namespaces
Variants

std::ctype<CharT>:: toupper, std::ctype<CharT>:: do_toupper

From cppreference.net
헤더 파일에 정의됨 <locale>
public :
CharT toupper ( CharT c ) const ;
(1)
public :
const CharT * toupper ( CharT * beg, const CharT * end ) const ;
(2)
protected :
virtual CharT do_toupper ( CharT c ) const ;
(3)
protected :
virtual const CharT * do_toupper ( CharT * beg, const CharT * end ) const ;
(4)
1,2) 공개 멤버 함수로서, 가장 파생된 클래스의 보호된 가상 멤버 함수 do_toupper 를 호출합니다.
3) 이 로캘에 의해 대문자 형태가 정의된 경우 문자 c 를 대문자로 변환합니다.
4) 문자 배열 [ beg , end ) 범위 내의 모든 문자에 대해 대문자 형태가 존재하는 경우, 해당 문자를 대문자 형태로 대체합니다.

목차

매개변수

c - 변환할 문자
beg - 변환할 문자 배열의 첫 번째 문자를 가리키는 포인터
end - 변환할 문자 배열의 끝 다음을 가리키는 포인터

반환값

1,3) 대문자 문자 또는 이 로케일에서 대문자 형태가 나열되지 않은 경우 c .
2,4) end

참고 사항

이 함수는 1:1 문자 매핑만 수행할 수 있습니다. 예를 들어 'ß'의 대문자 형태는 두 문자 문자열 "SS"입니다(일부 예외 사항이 있음 - «Capital ẞ» 참조). 이는 do_toupper 로 얻을 수 없습니다.

예제

#include <iostream>
#include <locale>
void try_upper(const std::ctype<wchar_t>& f, wchar_t c)
{
    wchar_t up = f.toupper(c);
    if (up != c)
        std::wcout << "Upper case form of \'" << c << "' is " << up << '\n';
    else
        std::wcout << '\'' << c << "' has no upper case form\n";
}
int main()
{
    std::locale::global(std::locale("en_US.utf8"));
    std::wcout.imbue(std::locale());
    std::wcout << "In US English UTF-8 locale:\n";
    auto& f = std::use_facet<std::ctype<wchar_t>>(std::locale());
    try_upper(f, L's');
    try_upper(f, L'ſ');
    try_upper(f, L'δ');
    try_upper(f, L'ö');
    try_upper(f, L'ß');
    std::wstring str = L"Hello, World!";
    std::wcout << "Uppercase form of the string '" << str << "' is ";
    f.toupper(&str[0], &str[0] + str.size());
    std::wcout << '\'' << str << "'\n";
}

출력:

In US English UTF-8 locale:
Upper case form of 's' is S
Upper case form of 'ſ' is S
Upper case form of 'δ' is Δ
Upper case form of 'ö' is Ö
'ß' has no upper case form
Uppercase form of the string 'Hello, World!' is 'HELLO, WORLD!'

참고 항목

do_tolower 를 호출합니다
(public member function)
문자를 대문자로 변환합니다
(function)
와이드 문자를 대문자로 변환합니다
(function)