The towupper() function is defined in <cwctype> header file.
towupper() prototype
wint_t towupper( wint_t ch );
The towupper() function converts ch to its uppercase version if it exists. If the uppercase version of a wide character does not exist, it remains unmodified.
The lowercase letters from a to z is converted to uppercase letters from A to Z respectively.
towupper() Parameters
- ch: The wide character to convert
towupper() Return value
- The towupper() function returns a uppercase version of ch if it exists. Otherwise it returns ch.
Example: How towupper() function works?
#include <cwctype>
#include <cwchar>
#include <iostream>
#include <clocale>
using namespace std;
int main()
{
setlocale(LC_ALL, "en_US.UTF-8");
wchar_t str[] = L"Ĵōhn Deńvėr";
wcout << L"The uppercase version of \"" << str << L"\" is ";
for (int i=0; i<wcslen(str); i++)
putwchar(towupper(str[i]));
return 0;
}
When you run the program, the output will be:
The uppercase version of "Ĵōhn Deńvėr" is ĴŌHN DEŃVĖR